cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Greg68
Helper III
Helper III

Button to be disabled for an hour after it's been clicked

Hello everyone,

 

I have a button in an a canvas app, that I would like that is get disabled for an hour after it has been clicked.

 

I used this code to make it disappear:

 

OnSelect: UpdateContext({presseddate: Now()+ (60/(60*24))})

visible: !(presseddate=Now()+(60/(60*24)))

 

Obviously this is not the right way, but was trying, and I have no clue on how to make it work,

Anyone can help please?

 

Thanks

4 REPLIES 4
Roverandom
Solution Supplier
Solution Supplier

Maybe the Timer control can help you.
In the button's OnSelect property, set a variable to start the Timer and logically set the Timer duration to one hour. From there, in the Timer's OnTimerEnd or OnTimerStart property, make the rest of the necessary modifications for your app.



Hi! I hope I was helpfull. Please always mark the answer that helped you, so others who need it will find it faster.



Roverandom is a book by J.R.R Tolkien. I'm a big fan of his works and as Frodo, Aragorn or Gollum are already widely used, I decided to use this nickname.
Roverandom
Solution Supplier
Solution Supplier

Forgot to mention, set the button's Display mode property to a variable. Then, in the OnTimerEnd property, of the Timer, define this same variable as you need (view, edit, disabled)...



Hi! I hope I was helpfull. Please always mark the answer that helped you, so others who need it will find it faster.



Roverandom is a book by J.R.R Tolkien. I'm a big fan of his works and as Frodo, Aragorn or Gollum are already widely used, I decided to use this nickname.
Roverandom
Solution Supplier
Solution Supplier

Like this:

PhotoGIF_8_5_2022_4_19_15_PM.gif



Hi! I hope I was helpfull. Please always mark the answer that helped you, so others who need it will find it faster.



Roverandom is a book by J.R.R Tolkien. I'm a big fan of his works and as Frodo, Aragorn or Gollum are already widely used, I decided to use this nickname.
Akash17
Responsive Resident
Responsive Resident

Hi @Greg68 

On Start of timer control set Start

Screenshot (619).png

OnTimerEnd of timer control use UpdateContext({ ButtonHide:false, Start:false })

Screenshot (620).png

On Duration property of timer control as per your requirement 3600=1hr

Screenshot (621).png

On visible property of Button If(!ButtonHide,true,false)

Screenshot (624).png

On OnStart property of your Button UpdateContext({ Start:true, ButtonHide:true });

Screenshot (625).png

 

I have taken reference from this nice post 

https://powerusers.microsoft.com/t5/Building-Power-Apps/Disable-canvas-button-for-given-time/td-p/12...

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,742)