Roles inside of applications
-
yannickHas successfully completed the online course Advanced (300)5 years ago #13058
Hi,
Is it possible to execute processes based on user roles?
Chris BouveretHas 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)Has successfully completed the online course Advanced (320)Has successfully completed the Intermediate CertificationHas successfully completed the Advanced Certification5 years ago #13065::Hi Yannick,
yes, this is possible. We provide a Business Object “User” for accessing Roles and User Attributes (see attached Screenshot). You can use it to get the Role of a looged in User and with a Condition Activity within Process Designer you can react on different Roles of Users. Hope this helps, if you have further questions please let me know.
Attachments:
You must be logged in to view attached files.Christopher Steinbach5 years ago #15625::Hi Chris,
I would like to have such a BO. How do you provide it? A link to a repo would be nice.
Why is such a functionality not already included as server action? Such a functionality is mandatory in many applications.
I’ve also noticed that the API documentation for the USERS object is missing in the Simplifier documentation. I’m guessing that the User_BO is built on that Object?!
Chris BouveretHas 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)Has successfully completed the online course Advanced (320)Has successfully completed the Intermediate CertificationHas successfully completed the Advanced Certification5 years ago #15632::Hi there,
you can create a new BusinessObject with the following Method: getCurrentUserRole and this code:
var user = Simplifier.User.getCurrentUser(); output.hasRole = false; if(user.roles) { if(user.roles.length) { Simplifier.Log.info("Roles", JSON.stringify(user.roles)); for (var i = user.roles.length - 1; i >= 0; i--) { if(user.roles[i].name === input.roleName) { output.hasRole = true; break; } } } else { throw new Error("User has no Roles"); } } else { throw new Error("User has no Roles"); }
this code uses the input Parameter “roleName” as String and returns the output “hasRole” as boolean (true/false)
It is based on the Simplifier BusinessObject Server API documented here
Hope that helps
You must be logged in to reply to this topic.