I am creating one report in this report I want to print all variants list which are associated with specific function(L4) entity in model.
how can I do this using script???
I can extract the list of all function now I want to extract variant which is associated with each function.
please help me guys it's very important for me....
Hi Ankit,
To get the list of variants, use the API function "objdef.Variants()". this function returns a list of definition object that are variant of "objdef", or an empty list if "objdef" has no variant.
ex:
var variants = myDefinition.Variants(); //myDefinition is an object definition or a model for(var i = 0; i < varaints.length; i++){ var myVariant = variants[i]; // write what you want to do with the variant here }
Best Regards
ps. Don't forget to use "F1" key from script editor to get help.
Example : Type "ObjDef" in the script editor, select the word and type "F1" to get all function available for object definition.
thanks alot Tricarico Romain :) this information is really helpful for me....
I have one more question here that I want to extract organizational unit and location which are associated with this variant..
I am able to extract the organizational unit and location which are associated with any function entity only..
suppose in a model I have "A" function(L4) entity and on this function entity one variant "B" is present(it may be a normal variant or master object) now I want to extract organization unit and location which are associated with "B".
please help me in this regards...:)
and please let me know if you have any confusion.....
Hi,
To get connected object to another one, use the function getConnectedObjs(objType):
this function return a list of object definitions.
In your case, to get the organizational unit connected to your variant :
var variants = myDefinition.Variants(); //myDefinition is an object definition or a model for(var i = 0; i < varaints.length; i++){ var myVariant = variants[i]; var uos = myVariant.getConnectedObjs(Constants.OT_ORG_UNIT); for(var iuo = 0; iuo < uos.length; iuo++){ var uo = uos[iuo]; //write here what you want to do with each UO connected. } }
Best Regards
Romain Tricarico