invalid argument types System.User and String issue

hi is there a function to convert the value inside “$currentUser” into a string that i can use to check if it is equal to either user or administrator?     alan
1 answers

The $currenUser object variable contains all attributes of the user entity. The Userrole is a reference between the System.User entity and System.UserRole entity. So thare is no way that you can comapre it like this bsed on a string.


Besides its not possible, I would never do it , as hardcode string comparisons will eventually break your app


But how to solve?

Is this a expression in a microflow decision?

In that case, add a retrieve before the decision and retrieve the role Administrator of the $CurrentUser

By using the token '[%UserRole_Administrator%]', you are save. When changing the Userrole name, the expression will change accordingly. When deleting the role, this expression will throw a model error.


Next check if the role is returned. If true, then the User is a Admin, otherwise not.



This is how microflow would look like


Is it for conditional visibility or other in the front-end; then it can be done using based on role