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?
Solved! Go to Solution.
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)
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
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.
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)
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
219 | |
212 | |
84 | |
57 | |
36 |