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?
Solved! Go to Solution.
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
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.
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
@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)
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.
@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.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
199 | |
71 | |
51 | |
42 | |
30 |
User | Count |
---|---|
268 | |
119 | |
94 | |
90 | |
81 |