How can I determine of a user has a role within a Microflow?

0
How can check if `$currentUser/System.UserRoles` has a specific role within a MF?
asked
2 answers
4

Hi James,

If you take a look at the system module domain model, there is a many to many relationship between the user table and user role table.

The “$currentUser” token provides the user object, so to get the user roles for the current user, you can retrieve over association the list of user roles and use the list operation find on the name attribute to find the specific user role you are looking for (you can use the user role token that you mentioned in your question), and then you can use an exclusive split to check if the object from the list operation is empty or not. 

 

Alternatively you can use an xpath constraint with retrieve from database to get the specific user role and then check for empty. 

The constraint would look something like this

[System.UserRoles = $currentUser]
[Name = '[%UserRole_Administrator%]'

 

Hope this helps

answered
4

Hi,

I would always prefer the XPath retrieve with the token, because then the platform handles changes in UserRole naming.

  • You cannot use the [%UserRole_???%] tokens in a list find
  • The correct constraint for the XPath is [id=’[%UserRole_???%]’] (not Name)

 

regards, Fabian

answered