Get role from System/User/RoleString

I’m trying to set a memory tag using the following expression on the system/client/RoleString which does not evaluate correctly.

The RoleString system tag is a list of strings, so I’m not sure how I would need to check the current users role against the system tag.

if ({[System]Client/User/RolesString} like 'Engineer', 1, 0)

I don’t believe this is working because ‘like’ isn’t a function in an expression. If I was use I would use the built in function hasRole(). From here you list the role your looking for, the user, and then the user source.

hasRole("Engineer", {[System]Client/User/Username},"user source")

If your looking at the current user and user source you should also be able to do just:

hasRole("Engineer")

It will return true if the user has the role and false if they don’t.

hasRole() worked perfect, thanks!

Clearing up a minor thing:
like is actually valid in the expression language, but this is not the right use case for it; like would be used if you had a single string and wanted to check its content.

3 Likes