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

On AppStart: find the ID from a SP table where the email adress is the same as the logged inn O365 user and then store the id as a var

Hi.

 

I have a list in SP Online with columns for ID, Name and email adress. When the app starts I want to find a match between User().EMail() and the email adress in the table, and then store the ID from the table as a variable to use later in the app.  

 

Whats the best method to get this done?

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @SkiDK ,

 

It is not suggested to apply the User() function into the formula directly, please try with this:

Set(VarUser, User().Email); Set(VarID,LookUp('SP list', Email = VarUser.Email).ID) 

Hope this helps.
Sik

View solution in original post

5 REPLIES 5
SkiDK
Solution Sage
Solution Sage

Hi @PowerTegga 

You can put this in OnStart:

 

Set(UserId, LookUp(SP_List, Email = User().Email, ID))

 

 Maybe a better idea is to create an object of your user, so you can always access all of your user information that comes from SharePoint, simply like this:

 

Set(User, LookUp(SP_List, Email = User().Email))
You can then access id by: User.ID as well as all other information that comes from your SP list

 

Hope this helps! 

Thank you for your answer, @SkiDK .

 

Your answer sounded like a good idea, but there seems to be a problem with this. See the strange error in my attachment. This is when I put the mouse over the Lookup function.

 

Do you have any idea what might cause this?

 

Hi @SkiDK ,

 

It is not suggested to apply the User() function into the formula directly, please try with this:

Set(VarUser, User().Email); Set(VarID,LookUp('SP list', Email = VarUser.Email).ID) 

Hope this helps.
Sik

View solution in original post

Hi @PowerTegga 

That's a weird error. What is the result if you do next:

 

LookUp(gmPersoner, Email = User().Email).ID

 

But as @v-siky-msft says, it is better to first store current user in a variable and then to use that object. Works for delegation and it also will be more performant. So what is the result if you try next: 

 

Set(varUser, User());
Set(varUserId, LookUp(gmPersoner, Email = varUser.Email).ID);

 

If that doesn't work, could you show the structure of 'gmPersoner', and if its a collection where and how it's initiated?

I found out that the problem was that I needed to save and close the app first. When I opened it again it was all good. I guess thats because the function is placed in "App" (Startup).

 

Thanks both of you.

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 (3,175)