cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
valw_47
Frequent Visitor

Disabling a button

Hello. I have a button that is configured as OnSelect to set a variable varStartTime to be the current date/time. I am trying to get the button to be disabled once this variable has populated with the date/time to avoid having the user select a new date/time.  My button code is this: 

Set(varStartTime, Now()); If(IsBlank(varStartTime), StartButton.Visible=true, StartButton.Visible=false), 

However, it does not disable the button.  Any suggestions on how to configure the button to do 2 functions for one click?

1 ACCEPTED SOLUTION

Accepted Solutions
anshulbatheja
Frequent Visitor

Set the variable with the current timestamp as you did on the onSelect attribute. Remove the if part. Instead you could just use the same code in the DisplayMode

If(IsBlank(varStartTime),DisplayMode.Edit,DisplayMode.Disabled)

 

View solution in original post

4 REPLIES 4
anshulbatheja
Frequent Visitor

Set the variable with the current timestamp as you did on the onSelect attribute. Remove the if part. Instead you could just use the same code in the DisplayMode

If(IsBlank(varStartTime),DisplayMode.Edit,DisplayMode.Disabled)

 

Thank you. When I apply the IF statement, I get an error that there are invalid arguments in the IF Statement.  I'm not sure what is wrong with it. 

valw_47
Frequent Visitor

I found my error. There was an additional context variable defined that once removed, this IF statement worked. 

Digital
Super User
Super User

What @anshulbatheja said if you want to disable the control.

 

If you want to make the control invisible, you could put the following:

 

IsBlank(varStartTime)

 

If there is no value in start time it will be visible. If there is a value it will disappear.

 

Personally I'd go with the disabled option but thought I'd mention

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,279)