TP

Hello,
a customer asked us to disable the editing of object attributes by  users, so I created a macro with "Object attribute is to be changed by modeling (vetoable)". The macro disabled all object attributes, but the customer wanted to disable only a subset of them.
Is it possible?

Thanks

Tatiana Piomboni

by M. Zschuckelt
Posted on Wed, 03/18/2020 - 21:48

You can create attributes as not being editable by users. You can access and modify them via script only then. When you create the Attribute type you have to clear the check mark "Editable". It's not possible to change that after creation of the attribute type. So for existing attribute types there is no such possibility. Either the user has write permissions to the object or he hasn't.

0
by Tatiana Piomboni Author
Posted on Thu, 03/19/2020 - 11:12

In reply to by M. Zschuckelt

Thanks for your reply.
Unfortunately there are many attributes and it's impossible to create them again.
Moreover some users must be able to edit these attributes.
For this reason I thought about using a macro.
Any ideas?

Tatiana Piomboni

0
by Kay Fischbach
Posted on Thu, 03/19/2020 - 14:29

Hi,

that's totally possible.

You'll have to decide for a whitelist or blacklist strategy (either you forbid by default all attributes to be edited and only allow a subset of attributes to be edited (whitelist) or your allow by default all attributes to be edited and only forbid a subset of attributes to be edited (blacklist))

Either way, what you need in your Macro is an array with all the attribute type numbers either of the attributes which you allow to be edited, or which you forbid to be edited.

For standard attributes you can just use Constants.AT_... (the API name which you can find in your ARIS method configuration). For custom attributes I highly recommend you retrieve the attribute type number with Context.getARISMethod().UserDefinedAttributeTypeNum("here goes the GUID which you can find in the ARIS method configuration")

Once you've got this whitelist or blacklist array, you just have to add a bit more logic to your main program that flips the macro property value event.veto from the default 0 to 1 (event.veto is how you already veto your attribute editing, right?)

It goes a little bit like this (demonstrating the blacklist strategy)

var currentlyAttemptedToEditAttrTypeNr = Context.getProperty("event.arguments").getValue("attribute_type_num")

var shouldVeto = false;

for each(var sigleForbiddenAttrTypeNum in blacklistArray) {
    if(currentlyAttemptedToEditAttrTypeNr == sigleForbiddenAttrTypeNum) {
        shouldVeto = true
    }
}

if (shouldVeto) {
    Context.setProperty("event.veto", "1")
}

 

Further note: you could probably significantly speed up the lookup of attribute type numbers, if you store them in a Javascript Map instead of a Javascript Array. Then you wouldn't have to iterate through your array checking every value, instead you would just ask the map for the value associated with your currentlyAttemptedToEditAttrTypeNr and it either returns something like an empty string if it's registerd in the map or null if it's not registerd in the map.

But I'm not too familiar with Javascript maps, so I can't tell you exactly how to do it.

 

0
by Tatiana Piomboni Author
Posted on Mon, 03/23/2020 - 13:03

In reply to by Kay Fischbach

Thank you very much Kay.
I tested your solution and it works.
I didn't know the key "event.arguments" for Context.getProperty.
In the ARIS Script online help I found this:

"event".
"event.id".
"event.component".
"event.veto".

Is there more documentation about this?

Thanks a lot
Tatiana Piomboni

0
by Kay Fischbach
Posted on Mon, 03/23/2020 - 22:35

In reply to by tatiana.piomboni

Hi Tatiana,

all I knew was that it is possible (cuz of course it is, otherwise I'd have to create a dust collecting feature request using ARIS Empower and that wouldn't be fun), but I didn't find it directly through the online script help either.

The way I found it was

  1. List all properties with Context.getProperties(). The thing that caught my eye was the "event.arguments" property (simply because it sounded like something related to your question).
  2. Retrieved "event.arguemnts" property with Context.getProperty(...). While debugging the debugger told me that this property has not just a simple primitive data type as a value, but it actually corrosponds to an object of a class you can find in your online script help: MacroEventArguments (ARIS Script > Methods for macros and transformations > Objects > MacroEventArguments).
  3. MacroEventArguments has a method called .getKeys(). I used that to find the String "attribute_type_num", which I could plug into the .getValue(...) method of MacroEventArguments to get the thing you were looking for.

I actually gave up on the thought of the online script help being comprehensive a while ago. If you really want to learn what you can do with ARIS Script you have to use it, write programs/test scripts, try things and work your own dev skills (the difference between using 90% of ARIS Script an using 99% of ARIS Script). The online script help certainly helps to an incredibly great degree, but if you want to get the absolute most out of ARIS script, just play around with it until you find what you need. The debugger and breakpoints are an absolute necessity for this act too.

0
by Tatiana Piomboni Author
Posted on Fri, 03/27/2020 - 12:01

Thank you.

 

0

Featured achievement

Question Solver
Share your expertise and have your answer accepted as best reply.
Recent Unlocks
  • CP
  • BZ
  • Profile picture for user TEF_Bernd
  • ПЦ
  • CR
  • 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