Expression language
Users and security
Reference for User Has Security Role and User Is in Team - check a user's security roles and team membership inside a condition.
Business rules often depend on who is involved: only a sales manager may approve a discount above 20%, only members of the Tier 2 Support team may close escalated cases. The two security checks, listed under Boolean Logical Operators in the picker, answer these questions inside any condition. They read the security roles and teams set up in your Dataverse organization, so they behave the same in both editions.
To assign records or tasks to a user or team, use the User, Team and Owner constants described in Values and constants.
User Has Security Role
Section titled “User Has Security Role”UserHasRole(user, role, includeTeamRoles)Returns Yes when a user has a security role.
| Parameter | Type | Required | Description |
|---|---|---|---|
| User | User, Owner, Lookup, Row or Unique Identifier | Yes | The user to check. |
| Security role (record or name) | Security role lookup or ID, or Text | Yes | The role, picked as a record or typed as its name, such as "Sales Manager". |
| Include roles from the user’s teams (optional) | Yes/No | No | Yes also counts roles the user has through team membership. Defaults to No. |
- A role picked as a record matches that role in any business unit. A role given by name matches any role with that name.
- An empty user, or an empty role name, gives No.
- When the user slot holds an owner that is a team, the result is always No: the check is about users.
- Turn on Include roles from the user’s teams (optional) when your organization grants roles through teams, otherwise users who get the role only from a team are not counted.
Example: in a validation on a quote, Or(discountpercentage ≤ 20, UserHasRole(ownerid, "Sales Manager", Yes)) allows discounts above 20% only when the quote’s owner is a sales manager, directly or through a team.
User Is in Team
Section titled “User Is in Team”UserInTeam(user, team)Returns Yes when a user is a member of a team.
| Parameter | Type | Required | Description |
|---|---|---|---|
| User | User, Owner, Lookup, Row or Unique Identifier | Yes | The user to check. |
| Team (record or name) | Team, Lookup or Text | Yes | The team, picked as a record or typed as its name, such as "Tier 2 Support". |
- An empty user or an empty team gives No.
Example: UserInTeam(ownerid, "Tier 2 Support") as a transition condition sends an escalated case straight to resolution when its owner is already in the Tier 2 Support team.