Profile picture for user Dilcarina Duarte

Hello Community!

Do you guys know how can I get attribute values of a model and objects using a script?

I want to get the value of an attribute that I've created - How can I do that?

Thanks in advance!

Regards,

Dilcarina

by Dilcarina Duarte Author
Posted on Wed, 02/13/2019 - 19:26

I got it:

var num = Context.getSelectedLanguage();

function getAttrStrValue(objectDef, p_attrTypeNum, num){

    var attr = objectDef.Attribute(p_attrTypeNum, num, true);

    if(attr.IsValid() == false)  return gs_Empty;

    return Packages.java.lang.String( attr.GetValue(true) );

}

To find the attribute type numbers: Aris Architect > Administration > Configuration > Method > Attribute types

Regards,

Dilcarina

1
by Kay Fischbach
Posted on Thu, 02/14/2019 - 08:52

In reply to by Dilcarina Duarte

Just adding information here about how to get the attribute type number, instead of hard-coding it into your script (no objections with how you use the number within the Attributes(...) method):

API Name

I'd recommend that you use the API Name, instead of the type number. It makes scripts much easier to read and understand. Additionally the API name will never change, while you can't be quite sure about that with the type number. You can use the API name by using

Constants.API_NAME

Example: For me the "Description/Definition" attribute has the attribute type number 9 and the API name AT_DESC.

Whenever I use

Constants.AT_DESC

directly within my script, the computer can look up the type number and replace the part that says Constants.AT_DESC with the integer 9 when the script is run.

You can find the API name in the column next to the type number column, which you already found in "Architect" > "Administration" > "Configuration" > "Method" > "Attribute types".

To look up the API name of attributes from within the "Attributes" window of object definitions and models, you can select the cell into which you would usually type the attribute value, and hit Ctrl+F1 to open the help page for the given attribute.

 

GUID instead of API Name

When you create custom attributes (attributes that aren't ARIS standard), the column "Type number" in "Architect" > "Administration" > "Configuration" > "Method" > "Attribute types" will show you a GUID of the attribute, instead of an attribute type number (easily distinguishable - type numbers are decimal and short, GUIDs are much longer, are hexadecimal and usually contain dashes). You can not use "Constants." with those. Instead there is a programmatic way to look up the type number for the GUID API Name.

ArisData.ActiveFilter().UserDefinedAttributeTypeNum("GUID_GOES_HERE");

Example: Imagine there is a custom attribute "Requirements", with the type number 265917 and the the API name column says 4329b3e3-2a44-33b0-1ea5-d8df42cdfc1b.

At the beginning of the script I would add the following line:

var AttrTypeNumRequirements = ArisData.ActiveFilter().UserDefinedAttributeTypeNum("4329b3e3-2a44-33b0-1ea5-d8df42cdfc1b");

This makes the computer look up the attribute type number a single time, and whenever I want to use it within the script, I just have to use the value assigned to AttrTypeNumRequirements.

1

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks
  • Profile picture for user freddy
  • Profile picture for user mikhubb
  • Profile picture for user harryratia
  • DC
  • ВА
  • PacMan

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock