cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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 @Anonymous ,

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.

 

Anonymous
Not applicable

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 @Anonymous ,

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
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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