cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Access rights is not working as expected

Hi, I'm fairly new to PowerApps and is still trying to navigate my way around it, but I have hit my head on a problem, which I can't seem to solve.

 

I have created a Sharepoint Online list as backend for the PowerApp. I now want to hide or show certain fields, depending on the users permissions. For that I have created another Sharepoint list containing the users email and which "departments" the user has access to. The latter i Yes/No chooses.

 

At OnStart for the App I have this:

 

Set(MyACLprofile; LookUp(UserCreationACL; UserEmail = User().Email))

 

 and on Visible for a field I have this:

 

MyACLprofile.ITAccess

 

But even though I have Yes (or Ja in Danish) for my user at the ITAccess column it will not show, and if I as a test put it into a label just to see what it contains, it returns false.

 

What am I doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

@Mhystique 

Haha.  I thought you would have tried that already.  If you take a look back at message #8 in the thread you will see I had suggested it.  I did wonder if you'd get delegation warnings but if there is no error message then its fine.

 

Lower(UserEmail)=Lower(User().Email)

 

Glad its working for you now.  Please remember to close the thread if the issue is solved.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

15 REPLIES 15
Highlighted
Super User III
Super User III

@Mhystique 

Nothing appears to be wrong with your code but I do have 2 ideas to help you troubleshoot.

 

#1 Perhaps the datasource needs to be refreshed.  Navigate over to the left side menu, click on your datasource and press refresh.

 

#2  Maybe you have selected on a different record than was expected.  Put this code MyACLprofile.ID into a label to find the record ID.  Then go to your Sharepoint list and confirm whether that record has the correct value for ITAccess.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted

Tried updating the connection many times, without luck. Unless it is extremely slow, I don't think that is the problem.

 

If I output ID in the label, I get nothing, but I don't have an ID column in the ACL list. I tried with Title which I have, but that returns also nothing. So maybe I have don't have the record, that I'm expecting, but why is that?

 

Shouldn't OnStart take the logged in users email and compair it with the ACL list, and put the informations into the variable MyACLprofile? Or maybe I have misunderstood something….🤔

I have attached a screendump of how my ACL list is filled out.

<offtopic> How the he.. do I change the subject, as I just realised I forgot to put a "not" in the subject. </offtopic>

 

@Mhystique
Is your datasource a SharePoint List? Every list item has an ID by default. Yours is likely just hidden. You can enable it in the show/hide columns menu.

Your LookUp code used in OnStart is fine but for some reason it is not finding any matching email.

Did you remember to click on the App in your left side menu and RUN ONSTART? This code only executes once when the program is opened.

Otherwise, try replacing the User().Email with an email directly copied over form the SharePoint (just as a test) and let me know if that works. Again, you must go to App RUn ONSTART after this change is made.
Highlighted

They should be Sharepoint lists - see attachement. Powerapps liste test is the main list, from which I'm building the app and hopefully a flow later on. UserCreationACL is the access list which I attached before.

I found the ID in the UserCreationACL list, and on top of that I remove myself and recreated to get a higher ID. Mine was 1, so just to be sure I have the correct one, so now it is 7.

 

I didn't run OnStart on the App before, thought it was the same as hitting Play at the top right.

 

If I put in my email directly instead of User().Email, it seems to work. I don't even have to press RUN ONSTART as the fields shows or hides depending on permission. So it seems it's not getting the information from the ACL list...

Highlighted

Put this code in a label to test whether your email matches what is in your user profile.

User().Email=“your_email@your_company.com”

If the label returns false then you should compare both text strings to determine why they are not matching. You could do this by putting them side by side in labels. If they look exactly the same try checking the length to detect blank spaces at the start or end of the text string.
Highlighted

Is it case sensitive? Cause then the problem is that. But how do I force everything to e.g. lower case?

 

<edit>

Shouldn't I just change OnStart to

Set(MyACLprofile; LookUp(UserCreationACL; UserEmail=Lower(User().Email)))

?

It doesn't seem to help.

</edit>

Highlighted

Yes text comparison is case sensitive. The right side of your formula is correct. However, you must also ensure the data is being stored as lowercase in your SharePoint List too (is UserEmail)

UserEmail=Lower(User().Email)

You can also try this but it might give a delegation warning (I can’t test on my mobile). That’s why I recommend changing your UserEmail in to lowercase within the SP List instead.

Lower(UserEmail)=Lower(User().Email)
Highlighted

The data in the Sharepoint list is in lower case. I typed it in myself and I just double checked. 😉

Highlighted

I thought you said case sensitivity was the issue in your message #7. Was that statement incorrect?

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (13,350)