cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Priyasantra
Microsoft
Microsoft

How to change the displaymode of a button based on sharepoint list user based

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 (Person/Group column)

2. Roles (Choice)

Priyasantra_0-1612427086728.png

 

 

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.

 

I used to achieve this by using the below formula in the Display mode of the button but the below formula no longer works 

 

With({usrRoles: LookUp('Access Control Admins', User().Email=User().Email, Roles)},

If("Admin" in usrRoles.Value, DisplayMode.Edit, DisplayMode.View)

)

 

Thanks in advance Regards Priya

1 ACCEPTED SOLUTION

Accepted Solutions

Hi@

Could you please check my formula again, I refer to the Users column in your 'Access Control Admins' list rather than the User() function.

It should be Users.Email = User().Email.

If(
    LookUp(
        'Access Control Admins',
        Users.Email = User().Email, // Please notice this line.
        Roles
    ) = "Admin",
    Edit,
    View
)

Regards,

Qi

Best Regards,
Qi

View solution in original post

3 REPLIES 3
v-qiaqi-msft
Community Support
Community Support

Hi@

 

If(
    LookUp(
        'Access Control Admins',
        Users.Email = User().Email,
        Roles
    ) = "Admin",
    Edit,
    View
)

 

Regards,

Qi

Best Regards,
Qi

Hi @v-qiaqi-msft 

 

No the user  column is not a multiple selection.  And using the above formula gives error. Please see attached

Priyasantra_0-1612430430400.png

Regards

Priya

Hi@

Could you please check my formula again, I refer to the Users column in your 'Access Control Admins' list rather than the User() function.

It should be Users.Email = User().Email.

If(
    LookUp(
        'Access Control Admins',
        Users.Email = User().Email, // Please notice this line.
        Roles
    ) = "Admin",
    Edit,
    View
)

Regards,

Qi

Best Regards,
Qi

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,573)