web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Set a variable if user...
Power Apps
Answered

Set a variable if user email exists in datasource

(0) ShareShare
ReportReport
Posted on by 254

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? 

Categories:
  • Verified answer
    seanbrogan Profile Picture
    430 on at

    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 Profile Picture
    269 on at

    @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)

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @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.

  • Manc_Gurl Profile Picture
    254 on at

    @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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard