You're currently browsing the Ignition 8.0 docs. Click here to view the latest docs.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This function is used by Ignition's Expression language.

 Returns true if the user has the given role. The username and usersource parameters are optional in the client scope, but required in the gateway scope.

 hasRole(role[, username][, usersource])

  • Parameters

string role - The name of a role.

string username - Optional. A username. Defaults to the current user.

string usersource - Optional. The usersource of the username. Defaults to the usersource of the current user.

  • Results

Bool - True if the specified user has the specified role, False if not.

Code Snippet
// This is an example using the default user and userSource:
hasRole("Administrator", "admin", "default")
Code Snippet
// This is an example using the current user and default userSource in the client scope:
  • No labels