cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sandie
Helper III
Helper III

Check if current user in a Sharepoint List

I want to check if the current user is in a sharepoint list called "Assignees"

 

The List Assignees has two columns:

User (People)

Job Types (Choice) 

 

I'm not quite sure how to approach this?  Do I have to pull out the Assignee emails into a collection or something first? 

 

Sorry, I'm more of a PHP person than a powerapps person!  Not quite sure how to frame my question.

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @Sandie ,

Yes - firstly something fundamental - rename the field User to something else - this is a reserved word.

So assuming now you have two fields UserName and JobType in your list Assignees - at App OnStart

Set(
   vUserName,
   User().FullName
);
ClearCollect(
   vAssignees, 
   Assignees
);
Set(
   vJobType,
   Lookup(
      vAssignees,
      Lower(UserName) = Lower(vUserName),
      JobType
   )
);
Set(
   vInList,
   !isBlank(vJobType)
)
   

Out of this you will have 

  • vJobType as the user's Job Type
  • vInList as a true/false is they are in the list.

 

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.

 

Thanks for your reply.

 

What I actually ended up doing was this:

 

Set(varUserEmail, User().Email);
If(CountRows(Filter('Assignees',varUserEmail in User.Email)) > 0,Set(varUserAssignee,true),Set(varUserAssignee,false));

 

 

Would there be any reason why your solution is better than mine in terms of best practice?  If so I could give it a go. 

Hi @Sandie ,

If you don't want the job title, CountRows on a Filtered list has the same effect as !IsBlank() on a Lookup - it is up to your preference. Neither are Delegable (neither is In), which is why I always do a collection to get rid of the annoying warning. You can shorten yours a bit (a boolean expression will automatically set a Boolean Variable to the same result) - also you can avoid InI am assuming that are the same text - Lower() avoids case sensitive issues, but again is not Delegable. Note also below the reference to the list field name for the user's mail.

Set(varUserEmail, User().Email);
Set(
   varUserAssignee,
   CountRows(
      Filter(
         'Assignees',
         UserEmail = varUserEmail    //this needs to be the name of the field in the list
      )
   ) > 0
)

 

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.

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,486)