How to – Hide and show controls in Canvas App based on security role of the user (Dataverse / Dynamics 365)

Sending
User Review
0 (0 votes)

Suppose we have the below Maker and Checker Canvas App, with two button one for raising the request and the other for approving and rejecting the request.

We have below custom security roles created in our Dynamics 365

  • Maker
  • Checker

Here we want Submit a Request button to be visible only to users with Maker security role and the Approve and Reject Request button to users with Checker role.

For this we can write the below formula on Visible property of the button.

Add the Users and Security Roles data sources first.

If(

LookUp([@’Security Roles’], Name = “Maker”, Role) in Concat(LookUp([@Users], ‘Primary Email’ = User().Email).’Security Roles (systemuserroles_association)’, Role & “;”),

true,

false

)

Based on email address of the user, we are comparing the Maker security role with all the different roles assigned to the user, which we are fetching from systemuserroles_association.

  • User function in Power Apps

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-user

  • Lookup function in Power Apps

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-filter-lookup

Hope it helps..

If(LookUp([@'Security Roles'], Name = "Maker", Role) in Concat(LookUp([@Users], 'Primary Email' = User().Email).'Security Roles (systemuserroles_association)', Role & ";"),
true,
false)
Advertisements