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 / Disabling a button bas...
Power Apps
Answered

Disabling a button based off multiple factors

(0) ShareShare
ReportReport
Posted on by 29
I have a Power App that users can use to sign up for various events. What I'm looking to do is disable the signup button for only the events in the gallery that meet one of two criteria - if either the user has already registered that the event, OR if there are no available spaces left. I previously had all of the buttons disabling if a user had enrolled for any event, with a separate condition for if there were no spaces available for a specific event.
 
What I have been asked to do is allow users to sign up for multiple events but prevent them from registering for the same event multiple times while still allowing them to sign up for others.
 
What I have sort of works. The only issue is that it's disabling the buttons for more than just what the user is signed up for. Here's the code I have for the DisplayMode property:
 
If(
    Value(ThisItem.OpenSeats) = 0,
    DisplayMode.Disabled,
    Text(LookUp('Event Registration',Email = varUserEmail, Email)) = User().Email, DisplayMode.Disabled, DisplayMode.Edit
)
How can I amend this to only disable the specific events that the user is registered for without affecting anything else? So far everything I've tried has broken it completely and refuses to disable anything. 

 
Categories:
I have the same question (0)
  • ronaldwalcott Profile Picture
    3,906 Moderator on at
    What is your data structure? Are you looking up the same table that you are navigating in the gallery?
  • QuikStudy Profile Picture
    29 on at
    What is your data structure? Are you looking up the same table that you are navigating in the gallery?
    I have a SharePoint list that populates the gallery with the information for the events (Events List) which includes and maintains the number of available seats. I'm using the value from the OpenSeats column in that list to determine if there are no seats available. User registrations are stored in a separate list (Event Registration), that includes the Name of the event they signed up for from 'Events List' along with their full name and email.
     
    I know there are probably cleaner ways to handle the data, but we're still pretty new to this and we needed something on short notice that would allow whoever would be managing it to easily add/remove events as well as easy access to the registration information.
  • Verified answer
    RyanAutomates Profile Picture
    141 on at
    Hi QuikStudy,
     
    I think your problem is in using the "Lookup" function, as it will return the first record in the Event Registration table that meet your condition. I haven't done Power Fx so recently, but I think if you could put something like this to match the ID of the record you are retrieving to the ID of the item selected in your gallery, it might fix your problem:
     

    LookUp('Event Registration', Email = varUserEmail And EventRegistrationID = ThisItem.Id, Email)

     

    (Or whatever you use in your situation to address a unique ID for each record - perhaps the ID column in the SharePoint record)

    Additionally, rather than using nested IF conditions, you could write your statement using "And"/"Or" operators like so:

     

    If( 

         Value(ThisItem.OpenSeats) = 0 Or Text(LookUp('Event Registration', Email = varUserEmail And EventRegistrationID = ThisItem.Id, Email)) = User().Email,

         DisplayMode.Disabled,

         DisplayMode.Edit

    )

     
    Hope this helps! :)
  • QuikStudy Profile Picture
    29 on at
    I needed to modify this slightly, but it did the trick. 
     
    If you're ever in the Philly area, I owe you a frosty beverage! 🍺
     
    I think your problem is in using the "Lookup" function, as it will return the first record in the Event Registration table that meet your condition. I haven't done Power Fx so recently, but I think if you could put something like this to match the ID of the record you are retrieving to the ID of the item selected in your gallery, it might fix your problem:
     

    LookUp('Event Registration', Email = varUserEmail And EventRegistrationID = ThisItem.Id, Email)

     

    (Or whatever you use in your situation to address a unique ID for each record - perhaps the ID column in the SharePoint record)

    Additionally, rather than using nested IF conditions, you could write your statement using "And"/"Or" operators like so:

     

    If( 

         Value(ThisItem.OpenSeats) = 0 Or Text(LookUp('Event Registration', Email = varUserEmail And EventRegistrationID = ThisItem.Id, Email)) = User().Email,

         DisplayMode.Disabled,

         DisplayMode.Edit

    )

     
    Hope this helps! :)

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard