cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Partisan
Post Partisan

Permission how to control control visibility based on datasource?

I have a sharepoint list with five columns.

Name, Email, IsAdmin, IsCreator, IsReader

Name = first name and last name of regisrated user

Email = users email adress

IsAdmin = true/false if the user is an admin

IsCreator = true/false if the user is an creator

IsReader = true/false if the user is an reader (normal user)

 

How can i use this datasource (sharepoint list) and hide/show controls based on the true/false values

IF CURRENT USERS EMAIL EXIST IN DATASOURCE AND HAVE ISADMIN TO TRUE THEN SHOW XXX CONTROL

ELSE IF ISADMIN IS FALSE THEN HIDE CONTROL

 

How can i do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Post Partisan
Post Partisan

Re: Permission how to control control visibility based on datasource?

Thank you.

I think i found a solution that seems to work so far.

When app starts in the OnStart function i have this:

ClearCollect(collAppUsers;Admin_List);;Set(IsEkeTr;LookUp(collAppUsers;EpostAdress=User().Email;EkebyTräk));;
ClearCollect(collAppUsers;Admin_List);;Set(IsSten;LookUp(collAppUsers;EpostAdress=User().Email;Stenhamra));;
ClearCollect(collAppUsers;Admin_List);;Set(IsAdmin;LookUp(collAppUsers;EpostAdress=User().Email;SuperAdmin))

(yes changed the names on my variables)

 

 

Then on a button i have on the DisplayMode function:

If(IsEkeTr;DisplayMode.Edit;DisplayMode.Disabled)

Afaik this works. The lookup looks up the EmailAdress column in my sharepointlist (Admin_List) and compares it to current user of the app and then takes the value from the column (superadmin, stenhamra or ekebyträk). This seems to give the current user the right permission to use or not use the button.

 

So if the user have true value in the columns EkebyTräk, Stenhamra or SuperAdmin it will make the button Edit else Disabled (ofc using the correct variable (IsEkeTr, IsSten or IsAdmin)

 

View solution in original post

3 REPLIES 3
Highlighted
Dual Super User
Dual Super User

Re: Permission how to control control visibility based on datasource?

Hi @Oskarkuus 

 

Set Visible property of control to

 

CountRows(
Filter(
SharePointList,
Email.Email = User().Email && IsAdmin = 1
)
) > 0

 

 

However, please be aware of a bug with Yes/No field in SharePoint and PowerApps

I would recommend using Text field in SharePoint to set Yes/No

 

https://rezadorrani.com/index.php/2019/04/14/powerapps-filter-sharepoint-yes-no-column-bug/

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Highlighted
Solution Supplier
Solution Supplier

Re: Permission how to control control visibility based on datasource?

Hi @Oskarkuus ,

Have you tried the solution above?

As a workaround you could also try setting user profile on as a global variable on the AppStart() property of the app.

 Set(MyProfile,Office365Users.MyProfile()); //or you can also use User().Email

On the controls you want to hide/show based on the tue/false values set Visible() property to:

If(MyProfile.Mail in AdminList.Value,true,false) //AdminList is your SP Data Source, AdminList.Value is the Email column.

Best of luck

----------------------------------------------------------------------------
Thanks,
K-A-R-L


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.

 

Highlighted
Post Partisan
Post Partisan

Re: Permission how to control control visibility based on datasource?

Thank you.

I think i found a solution that seems to work so far.

When app starts in the OnStart function i have this:

ClearCollect(collAppUsers;Admin_List);;Set(IsEkeTr;LookUp(collAppUsers;EpostAdress=User().Email;EkebyTräk));;
ClearCollect(collAppUsers;Admin_List);;Set(IsSten;LookUp(collAppUsers;EpostAdress=User().Email;Stenhamra));;
ClearCollect(collAppUsers;Admin_List);;Set(IsAdmin;LookUp(collAppUsers;EpostAdress=User().Email;SuperAdmin))

(yes changed the names on my variables)

 

 

Then on a button i have on the DisplayMode function:

If(IsEkeTr;DisplayMode.Edit;DisplayMode.Disabled)

Afaik this works. The lookup looks up the EmailAdress column in my sharepointlist (Admin_List) and compares it to current user of the app and then takes the value from the column (superadmin, stenhamra or ekebyträk). This seems to give the current user the right permission to use or not use the button.

 

So if the user have true value in the columns EkebyTräk, Stenhamra or SuperAdmin it will make the button Edit else Disabled (ofc using the correct variable (IsEkeTr, IsSten or IsAdmin)

 

View solution in original post

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,234)