How to get current Entity?

Hello TDM-Team,
I need to customize the Entity form - to add a button which will add technical fields at the current opened Entity (for instance .CHANGE_TIMESTAMP). According to your comments in previous topics I have already added a button and created function which controls OnClick event. But I don’t know how can I get the current opened Entity. Please, could you help me?

Thank you.

Martin

Hi,

I am not sure what you wish to add and where exactly (technical fields).

I did the following:

  1. I created new user package via File | New Package menu item (Expert mode must be enabled)
  2. I edited the entity form and added there new button and changed its name to myButton.
  3. In package explorer I located the new package, right clicked the Script folder, added there new script and renamed the script to FmPEREntityEdit (BTW: this is the name of Entity Properties form. The name must be set to this if we want to use events.)
  4. I created the following function:

function myButtonOnClick()
{
var Log = System.CreateObject(“Log”);
Log.Information(Entity.Name);
}

This function writes entity name to Log.

Note: the name of the function is made of button name and event name. myButton and OnClick.

To access the entity name, just use Entity.Name.

For more information please read the Customization Sample topic in User Guide. For complete list of objects and properties please look at the Reference Guide. Both documents are accessible via Help menu.

If you need additional assistance, write us here or send us a messsage to modeling@quest.com (you can write us email in Czech, if you like).

Regards,

Vaclav

Entity.Name was the answer :slight_smile: Thank you very much, I didn’t realise that I can use this attribute when I want to find the name of the current Entity (selected entity - where the button was pressed).

OK. I am glad it works for you. Feel free to contact us again in case you need our help.

Have a nice day,

Vaclav

Hi Vaclav

How do I get the current entity in a macro when one right clicks on the entity. I want to execute a macro on the selected number of entities.

I tried to look at how the new macro Infer Relationship on selected works, but couldn’t find the source.

You have been a great help.

Thanks

Hazi

Hi Hazi,

I’ll publish a new article with detailed explanation on Monday.

Regards,

Vaclav

Thanks Vaclav,

I found Beta3.5.2_Macro.swf tutorial at http://modeling.inside.quest.com/entry.jspa?externalID=3283&categoryID=273 which solved my problem.

I just had to dig harder.

Hazi

Hi Hazi,

I am glad you found it.

BTW: Today I published new article that explains how to iterate selected objects:
http://blogs.inside.quest.com/modeling/2010/11/09/run-macro-for-selected-entities-and-store-ddl-preview-to-files/

Regards,

Vaclav