How to get current user role in JS Script shape?
-
Christian2 years ago #30097
Hi all
rather a short question, but I do not find this information in the documentation: how to get the roles of the currently logged in user in the JS Script shape in the process designer? In the code snippets, there is only “getUsername”…
Thank you!
DanHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)2 years ago #30106::Hi Christian,
you can use the methode “getCurrentUserRole” of the Server Side Business Object “ITIZ_User” which is availabe in the Simplifier standard content.
As an input parameter you can name a role and the business object will return a boolean whether the executing user has this role or not.Hope this helps!
Best regards,
DanDanHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)2 years ago #30110::Hi Christian,
yes you summarized it correctly.
Inside the process designer you’d have to use this business object and save the result (true / false) as a variable.For the UI you want to change, you can then check if this value is true or false and print display the desired text. You can do this using condition and UI action shapes or use expression binding which could look something like this:
{= ${variableHolder>/UserHasRoleXY} ? ‘user has role’ : ‘user does not have role’}
Best regards,
Dan
Christian
You must be logged in to reply to this topic.