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 button in a ...
Power Apps
Answered

Disabling button in a gallery.

(0) ShareShare
ReportReport
Posted on by 54

Hi, 

 

I have a gallery connected to CDS Account records.  I have a field in account called "Picked".  If Picked = Blank, then the button is disabled, otherwise it's not.

 

When I press the button, I update the record so that Picked is not blank.  But "auto-disable on select" time isn't long enough for the refresh of data, so the button isn't disabled and the users think that it hasn't worked so press again and again and again...

 

Does anyone have a better idea of how I can do this?

 

Thanks...

 

John

Categories:
  • BegeNCSU Profile Picture
    131 on at

    One tactic I often try when a user is making changes is set all the buttons and fields display mode to a context variable. When the screen is first opened I add UpdateContext({conMode:Edit}) to the OnVisible property. Then I enclose any OnSelect action with UpdateContext({conMode:Disabled}) as the beginning and then UpdateContext({conMode:Edit}) at the end. Then you can set the DisplayMode of the control to conMode.

     

    image.png

     
  • BigJohn Profile Picture
    54 on at

    Thanks for the reply!

     

    Yea I thought about doing something similar.  The problem is that the button is part of a gallery card, so doing that will set all the buttons for all the items in the gallery to Edit/Disabled.

  • BegeNCSU Profile Picture
    131 on at

    Hey, great minds, am I right?

     

    If you only want some of the buttons to be disabled, then you could either only apply the conMode to the buttons that you want disabled while they're waiting on a response or setup a different conMode for each button that you want that functionality for. So you could have a ConModeName, ConModeTitle, ConModeManager....

     

    Another thing that I often do is instead of disabling the controls I just add a label that takes up the entirety of the app and in the text have "Please wait while your data is being saved". Though that might be better suited for a form where you wait till the end to save as opposed to a single control/change.

  • BigJohn Profile Picture
    54 on at

    Haha absolutely!

     

    As I mentioned though, the button is within the gallery "card" (not sure if that's the right terminology) so the button appears in all items in the gallery.  So there's no way I can think of that using a variable that would only disable the button that's been pressed?

     

    Hope that makes sense.

  • Verified answer
    BegeNCSU Profile Picture
    131 on at

    How about adding another context variable that is set to that Item? Say your gallery cards are demographics (name, title, manager). Then when a change is made for that control within the item, you can set the OnSelect to UpdateContext({conMode:Disabled , conItem:ThisItem.Demographic}) then the control's display mode could be If(ThisItem.Demographic=conItem,conMode,Edit)

  • v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @BigJohn ,

     

    Is your purpose to updating the record with value must be contained in Picked field? If so, you could workaround this by setting below formula in the OnSelect property of the button:
    If(!IsBlank(ThisItem.Picked),Patch(....),Notify("Picked mustn't be empty",NotificationType.Error)))


    Regards,

    Mona 

  • BigJohn Profile Picture
    54 on at

    Hi BegeNCSU,

     

    Thanks for that.  I did as you said and created another context variable of the item called pickedItem, then on the Display Mode of the button I did:

    If(pickedItem.Account = ThisItem.Account, DisplayMode.Disabled, If(!IsBlank(ThisItem.Picked), DisplayMode.Disabled, DisplayMode.Edit))

    This has brought it's own little quirks but for the most part it's what I wanted to achieve.

     

    Thanks for all your help!

     

    John

  • BegeNCSU Profile Picture
    131 on at

    Great to hear, keep plugging away!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi, 

    i have same scenario to disable the dropdown for specific values. so what i have done trying to listdown the below steps may be it will help you

    1. i have one column associated with that dropdown so onChange event i have patch it's value to that list and refresh the data source.
    2. go into that gallery dropdown control displaymode property and check thisitem.value = specific value( make your value) and then set display mode disabled or edit

    so in your case check is your picked value is blank or not then set display mode disabled or edit in button displaymode. and when you clicked on button so do your update picked value and then refresh the datasource.

     

    try it and let me know if it helped

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard