cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Manc_Gurl
Helper IV
Helper IV

Set a variable if user email exists in datasource

I need to disable a button on a screen if the current logged in user email isn't listed in a table in my datasource.  I am already collecting the logged in users email.  Is there a way I can search the datasource table and set a variable if that email address exists in the datasource and perhaps set the variable to something else if they don't exist or set it to blank? 

2 ACCEPTED SOLUTIONS

Accepted Solutions
seanbrogan
Responsive Resident
Responsive Resident

There are probably a few ways to do this. One way is to do a lookup on the email address. If it returns blank then you know you can disable the button. My method is probably not the best way but it might look something like this...

 

Set(LookUpVariable, LookUp( EmailTable, TableID = LoggedIn_ID)); 

If(IsBlank(LookupVariable), Set(ButtonVariable, false),Set(ButtonVariable,true));

 

Then in the visible control for the button just put ButtonVariable

 

View solution in original post

RandyHayes
Super User
Super User

@Manc_Gurl 

Best to just get a snapshot variable of the fact of them being or not being in a datasource.

    Set(glbInList, LookUp(yourDataSource, emailColumn = yourAlreadyGatheredEmailVar, true))

 

This will set glbInList to true if the user exists and you can then use that in your app to enable or disable items based on it.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

4 REPLIES 4
seanbrogan
Responsive Resident
Responsive Resident

There are probably a few ways to do this. One way is to do a lookup on the email address. If it returns blank then you know you can disable the button. My method is probably not the best way but it might look something like this...

 

Set(LookUpVariable, LookUp( EmailTable, TableID = LoggedIn_ID)); 

If(IsBlank(LookupVariable), Set(ButtonVariable, false),Set(ButtonVariable,true));

 

Then in the visible control for the button just put ButtonVariable

 

Rivius
Resolver III
Resolver III

@seanbrogan 's suggestion would probably work

I would probably put in the DisplayMode property of the button you want to disable something like, If(!IsBlank(Lookup user email stuff here), DisplayMode.Disabled, DisplayMode.Edit)

RandyHayes
Super User
Super User

@Manc_Gurl 

Best to just get a snapshot variable of the fact of them being or not being in a datasource.

    Set(glbInList, LookUp(yourDataSource, emailColumn = yourAlreadyGatheredEmailVar, true))

 

This will set glbInList to true if the user exists and you can then use that in your app to enable or disable items based on it.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes @seanbrogan Thank you both. Both options provided work so I have accepted both solutions.  However, I decided to go with Randy's option as it was a little bit cleaner.  Thanks to you both for your help.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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