Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Disable a button after it is pressed once

(0) ShareShare
ReportReport
Posted on by 25

Hello community;

 

I have created a voting app and i have a button and I want to make sure once a user presses it once , the button will be disabled so that a user can only vote once not multiple times.

 

I followed this guide but i got some errors.

https://powerusers.microsoft.com/t5/Building-Power-Apps/Disabling-a-button-once-it-is-pressed/td-p/293189

 

Team, can anyone suggests something.

 

disable button.PNG

 

Thank you.

 

 

Categories:
  • Paladin Profile Picture
    34 on at
    Re: Disable a button after it is pressed once

    You could also set the button DisplayMode to the following.

    If (Self.Pressed,DisplayMode.Disabled)

  • RThind Profile Picture
    on at
    Re: Disable a button after it is pressed once

    You have spelt it as 'Disable' so its incorrect. It should be:

    If(IsVoted, DisplayMode.Disabled, DisplayMode.Edit )

  • BrianS Profile Picture
    2,407 Super User 2024 Season 1 on at
    Re: Disable a button after it is pressed once

    First - regarding the visibility of the button. If you want the button to not show, put the code in the Visible property. All you need is the variable, not any test if your variable is Boolean. If you are using Set(IsVoted,true) then you can just put !IsVoted in the Visible property and the button will not be visible once it is pressed.

    The Disabled property will show the button, but will not allow it to function, and it will use a separate set of colors. This is often preferable, but in your case the Visible is fine.

    The code I presented earlier to test for the presence of voting in the list should keep the data from being written if there is already a vote in the list. It would not disable the button - that would be up to the code above. If it is recording the data then there is an error in the code and it is not evaluating correctly.

  • Raou Profile Picture
    25 on at
    Re: Disable a button after it is pressed once

    Hey @BrianS 

     

    I tested it and it works and I can receive the warning message successfully.

     

    However, the button is not disabled and if I click on the button, my voting will still be saved in the datasource.

     

    Any advise on this.

     

    Thank you.

  • Raou Profile Picture
    25 on at
    Re: Disable a button after it is pressed once

    Thank you @VijayTailor for your response.

     

    However, the button is still visible.

    I put below code in "OnSelect" property 

    Set(IsVoted,true)

     and 

    if(IsVoted,DisplayMode.Disable,DisplayMode.Edit)

    under DisplayMode

     

    I can still see the button 

    display mode.png

  • BrianS Profile Picture
    2,407 Super User 2024 Season 1 on at
    Re: Disable a button after it is pressed once

    This will work, however, it will not keep someone from closing the app and then re-opening it and voting again. If you want to make sure people only vote once, you will need to look thru the data and make sure they haven't voted yet.

    Something like:

    If(IsBlank(LookUp( dataSource, User().email=List_email)),

    SubmitForm(Vote),

    Notify("Sorry - you already voted",NotificationType.Warning))

    where List_email is where their email is stored in dataSource

  • Vijay Tailor Profile Picture
    2,961 on at
    Re: Disable a button after it is pressed once

    Hi @Raou ,

    YOu can Use like below.

    Create A new Global variable like - Use the below code OnSelect Property of Button.

    Set(IsVoted,true)

     and use the conditional step for the display mode of the button.
    like below

    if(IsVoted,DisplayMode.Disable,DisplayMode.Edit)

    Thanks,

    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."-Vijay

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