Expression Tag Referencing [System] Tags

I am trying to create an expression tag (boolean type) that is set based upon a user’s role using the following expression:

hasRole("Administrator")

This results in an Evaluation Error (Function ‘hasRole(role, username, usersource)’ does not work with 1 arguments.

I have also tried to create an expression tag (string type) using the following expression:

{[System]Client/User/RolesString}

This results in a REFERENCE_NOT_FOUND error.

Can expression tags reference tags located in the System folder? If so, what am I doing wrong?

From the error message, it would seem the hasRole() expression expects you to pass it a username and usersource as well as the role name.

I tried the following with success:

hasRole("Administrator", "MyName", "dbauth")

but the following gives me a type mismatch error on argument 1:

hasRole("Administrator", {[System]Client/User/Username}, "dbauth")

I didn’t want to hard code the user name into the expression so would like to use the system tag instead but that still doesn’t work.

Is the tag you’re creating also a client tag? You can’t access {[System]Client/User/Username} otherwise.

I just created a Client tag containing expression "hasRole(“Administrator”) and it works fine. Why can’t an expression tag located in the project’s default tag provider access [System] tags? I can bind custom properties to those without any issues.

Client system tags, just like the client tag you created, exist only in the running client, with each client instance having its own tags with their own values.

It sounds like you were initially trying to create a regular, gateway-scoped, expression tag. There's no access to client system tags because there's no client associated with anything running on the gateway.

Docs explain it better than I can: https://docs.inductiveautomation.com:8443/display/DOC79/System,+Client,+and+Diagnostic+Tags

Thanks Kevin!

Yep, that’s what I was trying to do. It’s easy to forget that the tags contained in the realtime tag providers are gateway-scoped and not client-scoped.