Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Disabling a button?

(0) ShareShare
ReportReport
Posted on by 58

Greetings,

 

I'm having an issue with trying to make a button become disabled after it's been pressed once. I tried following the solution in this post but it simply doesn't work. I get "error token" under the button's name in the OnSelect field. I feel like the way one disables a control changed since then.

 

What I need is once the button was pressed, run a process which works and then disable itself. Right now it runs fine, but the disabling part doesn't work...it keeps the button up there.

 

Any help is greatly appreciated!

Categories:
  • andersonmendoza Profile Picture
    9 on at
    Re: Disabling a button?

    It worked for me but not using the function Updatecontext({key: value}) else creating a variable statusDisplay and setting this using Set() function when the App Start:

    andersonmendoza_0-1686592312889.png

    Set(statusDisplay;DisplayMode.Edit)

    After I set the Display Mode (Button property) with StatusDisplay variable:

    andersonmendoza_1-1686592617283.png

    I set OnSelect on the Button to:

    andersonmendoza_2-1686592876693.png

    Set(statusDisplay;DisplayMode.Disabled)

     

    And voilà!!!!

     

    Many Thanks Jason!!!

  • rfont13 Profile Picture
    2 on at
    Re: Disabling a button?
    Good morning. In my case I solved the problem by applying a variable and a collection. I explain it. 
    This Button is on a Gallery. I have created on property OnStart of the page Clear (DisaButton);; Set(
    DisableButton;
    false
    ) Then in Onselect of the button I apply
    Set( DisableButton; true );; Collect( DisaButton; ThisItem.'Name (field_2)' ) and finally to the DisplayMode property of the button I apply
    If(
    ThisItem.'Name (field_2)' in DisaButton;
    DisplayMode.Disabled;
    DisplayMode.Edit). When you click the button it is deactivated. Now what I would like to do is when the page loads this button is disabled if the record is already in the sharepoint list. I've tried several options, but it just doesn't work. Does anyone have any ideas?
  • JTA88 Profile Picture
    43 on at
    Re: Disabling a button?

    Did you ever find a fix for this? I've just come up against the same problem!

  • faisal123 Profile Picture
    2 on at
    Re: Disabling a button?

    The Same issue I got where I've  a list if I disable the button on one item, it does hold the state for other items too.
    I need to click on the button which is like 'save' against the item then it should disable or hide the save button and the second button should be visible on the same spot which is an 'update' button but I've tried all ways couldn't figure out. Seems like it's a bug in powerapps because I have achieved same kind of logic in Macros.

  • martinzima Profile Picture
    2 on at
    Re: Disabling a button?

    Thanks @Jason_Hough, I realise your solution was posted a while ago now but hoped you could help me - I am trying to integrate your solution into my project however I am not quite sure what to do with the code currently driving the DisplayMode on the button.

     

    i.e. requirements...

    1. If payment due date is in the future, disable the 'Chase Payment' button (otherwise enable it)
    2. Disable 'Chase Payment' button when users clicks it (and triggers the flow).

     

    Previously I had:

    SendChaseButton.DisplayMode
    If(ThisItem.DueDate<TimeNow,DisplayMode.Edit,DisplayMode.Disabled)
    
    SendChaseButton.OnSelect
    PowerAppsbutton.Run(ThisItem.ID);SendChaseButton.DisplayMode=DisplayMode.Disabled #<-- Doesn't work

     

    I updated the code to use a context variable as you recommended:

    SendChaseButton.DisplayMode
    ButtonStatus
    
    SendChaseButton.OnSelect
    PowerAppsbutton.Run(ThisItem.ID);UpdateContext({ButtonStatus:DisplayMode.Disabled})

     

    ... however, while this does now disable the button when the user clicks it, it no longer sets it's initial status -- I tried to incorporate the context variable with my previous If statement, however it would not accept this syntax.

     

    Any help you can give me would be grately appreciated!

  • davidstone Profile Picture
    471 on at
    Re: Disabling a button?

    Ok, it looks like you're using updatecontext to enable the button.

     

    Simpler solution:-

    Set(EnableAddPhotos, true)

    And then change the DisplayMode property of your add photos button to 'EnableAddPhotos'.

     

    You'll want to also initially set that variable to false, which you could do in the OnVisible for your page.

  • davidstone Profile Picture
    471 on at
    Re: Disabling a button?

    You've found me @sajarac - looking at your post now!

  • Community Power Platform Member Profile Picture
    on at
    Re: Disabling a button?

    let me know what the issue is, as i have an app that does kind of what you are reffering to

  • Sajarac Profile Picture
    3,265 on at
    Re: Disabling a button?

    Lost of activity in this topic!!

     

    I wish we can find someone who can solve the issue of saving pictures and retrieven in a share point list

    😞

  • davidstone Profile Picture
    471 on at
    Re: Disabling a button?

    Aw, I just saw your reply come in as I was explaining how to do it - I'll stop typing! Smiley Very Happy

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1