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

If statement: Checking a users email against multiple emails from a SharePoint list? Is it possible?

Hi!

 

I've been researching into users and all the metadata that goes with it, and have come across a question for an idea I have, but don't know how to implement.

 

So, a user is logged into an app. Their email is test@email.com. I have a sharepoint list of emails. 

 

I want to have a filtered gallery where the users email is checked against the sharepoints list of emails, and if true, show specific set of rows, if not, show nothing. 

 

So if test@email.com was in the list, the user would gain access to view specific rows in the gallery. I am more focused on the issue of checking the user email against the list of emails. 

 

Sorry if it poorly explained!

Thanks in advance 🙂

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @timl 

 

Do you want to check if the login user email is in the EmailsColumn, right?

I agree with @timl 's workaround, but 'CountRows' function is also nondelegable, so I just come to make a little change to make it work.

Set OnStart of App: 

 

Set(currentuser,User().Email)

 

Modify the codes as below:

 

If(IsEmpty(Filter(EmailSharepointList, EmailsColumn=currentuser )) ,
Blank(),
OtherSharepointList
)

 

Hope this helps.

Sik

 

View solution in original post

4 REPLIES 4
timl
Super User
Super User

Hi @Alfie_Smith 

The filter function would allow you to filter a list by email address.

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-filter-lookup 

The syntax you would use would look like this:

Filter(YourSharePointList, YourEmailColumn="test@email.com")

Ah I should've explained better.

 

So theres two sharepoint lists in this.

The sharepoint list with the emails, and other with some data. 

My idea is best described in the following pseudo-code:

 

If(User().Email = EmailSharepointList.EmailsColumn, OtherSharepointList, Blank())

 

The issue is shown in bold. Where the User().Email equals any of the emails in the 'EmailsColumn' in EmailSharepointList show the OtherSharepointList data in the gallery. I don't know how to check the user email against all the records in EmailSharepointList. 

 

I was considering using a hidden gallery with all the emails.

 

Hope that clarifies 😃

 

Hi @Alfie_Smith 

I think this is what you're trying to achieve.

Hopefully, you get the gist of what the formula does. Feel free to post back if I've misunderstood you.

If(CountRows(Filter(User().Email = EmailSharepointList.EmailsColumn)) > 0,
   OtherSharepointList,
   Blank()
)

Just tagging @Pstork1 here, in reference to your other post. He is correct about saving the user's email as a variable in the App OnStart to avoid delegation problems.

Set(currentuser,User().Email)

 

Hi @timl 

 

Do you want to check if the login user email is in the EmailsColumn, right?

I agree with @timl 's workaround, but 'CountRows' function is also nondelegable, so I just come to make a little change to make it work.

Set OnStart of App: 

 

Set(currentuser,User().Email)

 

Modify the codes as below:

 

If(IsEmpty(Filter(EmailSharepointList, EmailsColumn=currentuser )) ,
Blank(),
OtherSharepointList
)

 

Hope this helps.

Sik

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,130)