Hi,
I'm new to making macro's and reports.
I'm trying to make a macro on the event Object created, that fills in the attribute Id.
I could use some global variable, perhaps an attribute on the database, that keeps the number of the next Id.
I managed to make a macro and link it to the event Object created, that part works. But now I have to make the code so that it only creates an Id for the symbol Process, and I have to look for the global variable and put it in the attribute of that new object.
I think the code should be something like this:
var allObjects = Context.getSelectedObjects(); for (var i = 0; i < allObjects.length; i++){ var symbol = allObjects[i].GETSYMBOOL; if(smbol = PROCESSYMBOOL){ var NextNr = DATABASE.ATTRIBUUTVALUE + 1; var nID = "O.Proc." & NextNr.TOSTRING(); Designer.setAttributePersistent(allObjects[i], Constants.AT_ID, nID, null); } }
But I don't know it exactly. Can somebody help me to make it work?
Thank you!
Hi Veerle,
first you have to differentiate, whether you really want the macro to be executed when an OBJECT is created or when an object occurrence is created.
If an object is created, it normally does not have an occurrence yet, so checking the symbol will not work.
But, if needed, this code will get an object's symbol(s!):
var objOccList = Designer.getOccs( allObjects[i] )
for(var j=0; j<objOccList.length; j++) {
var nSymbol = Designer.getSymbol(Designer.getModel(objOccList[j]), objOccList[j])
}
The only symbol you can get from an object definition is the "default symbol" which is used as default, when the a new occ of this object should be placed in a model:
var nDefaultSymbol = Designer.getDefaultSymbol( allObjects[i] )
Same as attribute types, there are symbol types as constants, beginning with ST_.
There are 3 symbol types for process symbols. Try to find out the correct one or look it up in the configuration/filter:
ST_PRC
ST_PRCS_1
ST_PRCS_2
You find these constants in the ARIS Script help: ARIS Script -> Methods for macros and transformations -> Constants ->Metamodel constants -> SymbolTypeNum
All component objects and their methods can also be found in the help. See ARIS Script -> Methods for macros and transformations ->Global objects -> Macro component interfaces.
You'll find the most useful methods in the Designer component interface. This can also be used to read/write an attribute from your Database object:
var attr =Designer.getAttribute(database, Constants.AT_NAME, Context.getSelectedLocale())
I hope this helps. BR, Torsten