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.
Team, can anyone suggests something.
Hi @Raou ,
YOu can Use like below.
Create A new Global variable like - Use the below code OnSelect Property of Button.
and use the conditional step for the display mode of the button.
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
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.
If(IsBlank(LookUp( dataSource, User().email=List_email)),
Notify("Sorry - you already voted",NotificationType.Warning))
where List_email is where their email is stored in dataSource
Thank you @VijayTailor for your response.
However, the button is still visible.
I put below code in "OnSelect" property
I can still see the button
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.
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.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Check out the Power Apps Community Call for January 2021
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!