web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to change the disp...
Power Apps
Answered

How to change the displaymode a button based on sharepoint user

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi, 

 

I need a help for my onboarding application 

 

I have created an Onboarding application as shown in the below screenshot

There are 4 buttons at the left handside

 

1. New Onboard

2. My Training

3.Intro Connect

4. Process Training

 

When the "New Onboard" is clicked it gives a pop up with a form as shown below

 

Priyasantra_0-1606495205257.png

 

Now my requirement is--> I have a share point list "Access Control" and in this list I have 2 columns 

1. User 

2. Roles

 

I want that the Dispalymode.Edit of this button should be true only for the the users those have their roles as "Admin" in the "Access Control list". Which means the users in the list with "Admin" as the role when clicks on the button should get this popup. Anyone apart from the admins should not be able to click this. They should only be able to view this and not edit. 

 

Please help me to set this code. 

 

Thanks in advance 

 

Regards

Priya

 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Priyasantra 

    Consider setting your DisplayMode formula to the following:

    With({usrRoles: LookUp('Access Control', User=User().Email, Roles)},
    
     If("Admin" in usrRoles, DisplayMode.Edit, DisplayMode.Disable)
    
    )

     

    Not sure how you are identifying the current user against the User column in your Access Control list, so substitute the User().Email to whatever attribute you are storing in your list that will match.

     

    I hope this is helpful for you.

  • Priyasantra Profile Picture
    Microsoft Employee on at

    Hi @RandyHayes , 

     

    I tried exactly what u recommended but receiving the below error

     

    Priyasantra_0-1606744118975.png

    And yes the user attribute is an email address 

     

    Could you please me with the same

     

    Regards

    Priya

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Priyasantra 

    You did not mention what kind of column User is in your list, but I am assuming since you have an error that it is a Person column.

    In which case, you need to change your formula to the following:

    With({usrRoles: LookUp('Access Control', User.Email=User().Email, Roles)},
    
     If("Admin" in usrRoles, DisplayMode.Edit, DisplayMode.Disable)
    
    )
  • Priyasantra Profile Picture
    Microsoft Employee on at

    Hi @RandyHayes 

     

    You are correct the column type used is Person or a group column. I have changed the code but still getting an error

     

    Priyasantra_0-1606755721410.png

     

    My sharepoint list looks like below:-

     

    Priyasantra_1-1606755795214.png

    Users is a Person or Name field and Roles has 2 choices 

     

    You have helped a lot before. I am expecting a great help from you.

    Regards

    Priya

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Priyasantra 

    So, as an FYI, when posting a problem, always mention the types of columns you have.  It will save a lot of time 🙂

     

    If it is a choice column, then you need the following:

    With({usrRoles: LookUp('Access Control', User.Email=User().Email, Roles)},
    
     If("Admin" in usrRoles.Value, DisplayMode.Edit, DisplayMode.Disable)
    
    )
  • Priyasantra Profile Picture
    Microsoft Employee on at

    Hi @RandyHayes 

     

    You are a super star. This worked.  

     

    I am sorry for taking much of your time before.

     

    Thanks again

    Regards

    Priya

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Priyasantra 

    Glad to hear that got it.  No worries on the time, it was more of your time that I was concerned over - I always figure if someone is posting a question on the forum, they are stuck on something and would like a response quickly.  Me...I've got nothing to lose 😉 

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 239

Last 30 days Overall leaderboard