cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

How do I find out if the current logged in user has edit access to the chosen item?

I have a sharepoint custom list with customized item permissions. 
The custom list item permissions is given to sharepoint groups.

How do I find out if the current looged in user has edit access to the chosen item?

Note:  The current user is not the user who created the item.

 

For Example:  List Item 1 has got these permissions:

ReadGrpA has read permissions.

EditGrpA, EditGrpB has edit permissions.

 

So in PowerApps when an UserB who is part of the EditGrpB chooses list item 1, the powerapp form must open in edit mode, else read mode.

 

8 REPLIES 8
Highlighted
Super User III
Super User III

Re: How do I find out if the current logged in user has edit access to the chosen item?

Insert a TextBox1 and put this formula:

LookUp(SharepointList,UserColumn=User().FullName,GroupName)

This will collect the GroupName based on the User logged in.

 

Then on the DefaultMode put this formula:
If(TextBox1 ="ReadGrpA",FormMode.View,FormMode.Edit)  

 

If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution

Highlighted
Frequent Visitor

Re: How do I find out if the current logged in user has edit access to the chosen item?

Hi 

Thanks for the reply.

Can you explain more please?

UserColumn what is that, I do not have a user column in my list.

I have only createdby and modified by columns in my list.

 

Also if the user chooses another item on the list, the user might have only read access.

I need to check item level permissions.

 

Thanks

 

 

Highlighted
Super User III
Super User III

Re: How do I find out if the current logged in user has edit access to the chosen item?

Am referring to a column in your permission table. What are the columns you have in your permission table where you have the various groups

Highlighted
Frequent Visitor

Re: How do I find out if the current logged in user has edit access to the chosen item?

I do not have custom permission table, I just want to use the manage access in list item. 

Highlighted
Super User III
Super User III

Re: How do I find out if the current logged in user has edit access to the chosen item?

Hi @prabhavs ,

There is no way to query a SharePoint security group from within PowerApps. It is currently "Under Review" - you can vote for it here.

The only solution for you would be to have a SharePoint list with the User's name in one field and the permission level in another. 

There are two built-in user functions in Power Apps - User().FullName and User().Email. Neither are delegable in queries, so a variable needs to be set at App OnStart to properly query with them. I will also use the user's name here, but email address can work as well. In this case, you could also set the permission level and I have done this below. So assuming your list name is SPPermissions and the fields are NameUser and AccessLevel, you could do the following - App OnStart

Set(vUserName,User().FullName);
Set(
   vLevel,
   Lookup(
      SPLevels,
      NameUser=vUserName,
      AccessLevel
   )
)

So then the FormMode of the form would be

If( 
   vLevel = ReadGrpA,
   FormMode.View,
   FormMode.Edit
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted
Frequent Visitor

Re: How do I find out if the current logged in user has edit access to the chosen item?

Thanks.

 

I was able to use flow and get the permissions for the given item for the logged in user.

 

Wish this was available in powerapps

 

Thanks to all for replying.

Highlighted
New Member

Re: How do I find out if the current logged in user has edit access to the chosen item?

Hi, could you please explain how you were use flow and get the permissions for the given item for the logged in user?

 

Thank you

Highlighted
Frequent Visitor

Re: How do I find out if the current logged in user has edit access to the chosen item?

this is what i came up with, it can be improved.

I am using the basepermissions and usereffectivepermissions to check for edit permission

 

I have a flow which is triggered from powerapps

With following parameters

varSiteAddress, varListName, varListItemID, varUserClaims

 

Note: varuserclaims : "i:0#.f|membership|" & Lower(User().Email)

 

I declare 2 array variables, 

varEditPermissionarray - permission object values for contribute, edit, fullcontrol.

varEditHighArray- this stores the high permission values for edit permissions

 

Send an Http request to get the role definitions

 

Roledef.PNG

 

ParseJson

Apply to each roledefinitions  

loopthropermi.PNG

Append to array  varEditPermissionArray , the base permissions

items('Apply_to_each_roledefinitions')?['BasePermissions']

Basepermissions.PNG

 

Within the same loop, check for the condition, before adding to EditHighArray., if the value exists in the EditHighArray.

 

items('Apply_to_each_roledefinitions')?['BasePermissions']?['High']

 

checkifvalue exists in edit high array.png

 

 

Declare Variable hasPermissions  String.

Declar VarEncodeUser and set the value to be function 

encodeUriComponent(variables('varUserClaims'))
 
In the next step GetUserEffectivePermissionsForListItem
effectiveuserpermission.png
 
Parse Json from the usereffective permissions
Body('GetUSerEffectivePermissions')
 
Then check if the usereffecttive permissions is found in the Permission array or higharray
OR condition :
varEditPermissionArray contains  body('Parse_Json_UserEffectivePermissions')?['d']?['EffectiveBasePermissions']
varEditHighPermissionArray contains body('Parse_Json_UserEffectivePermissions')?['d']?['EffectiveBasePermissions']?['HIgh']
checkifusereffectivepermission.png
 
Return the string value  hasEditPermissions. or you can initialize a Yes or No variable and send back to powerapps.
 
 
The next pic gives the full flow.
 
FullflowScr1.png
 
FullFlowScr2.PNG

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,591)