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

Disable and enable button base on time and Click

I just want to ask if there is a way in which i can Disable a button after it has been clicked and enable it back the following day.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @damilola79 ,

You are doing this to set the data

ClearCollect(
   onClickHandler,
   {
      ClickEventDate: Now(),
      User: User().Email
   }
)

This may be a bit of overkill, but I am trying to avoid potential errors

With(
   {
      wEvent:
      Lookup(
         onClickHandler,
         User=User().Email
      ).ClickEventDate
   },
   If(
      IsBlank(wEvent) 
      DisplayMode.Edit,
      If(
         DateDiff(
            wEvent,
            Now(),
            Days
         ) >= 1,
         DisplayMode.Edit,
         DisplayMode.Disabled
      )
   )
)

Note that this formula tests for a 24 hour difference. If you want just the next day, use Today() instead of Now().

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

9 REPLIES 9
dariobois
Resolver II
Resolver II

Hi,

 

You need to store the click event date and who clicked the button, into a database or locally on the device, then, check if that variable is older than today to shows the button as "Display.Edit"

 

For Example. Try this,

"On select" Button event:

 

 

ClearCollect(
    colEnableButton,
    {
        ClickEventDate: Now(),
        User: User().Email
    }
);
SaveData(
    colEnableButton,
    "colEnableButton"
)

 

 

"DisplayMode" Button property:

 

 

If(
    Or(
        DateDiff(
            First(colEnableButton).ClickEventDate,
            Now(),
            Days
        ) >= 1,
        IsEmpty(colEnableButton)
    ),
    DisplayMode.Edit,
    DisplayMode.Disabled
)

 

 

"OnStart" App event:

 

 

LoadData(
    colEnableButton,
    "colEnableButton",
    true
)

 

 

 

NOTE:

My example works only on mobile devices or powerapp desktop application because "SaveData" and "LoadData" functions are an Offline features not supported by browsers.

You can store the "colEnableButton" collection into a databese too, then get it by the User().email, as an "ID", to be sure that the button will be disabled to him if corresponds.

 

Regards!

Please it didnt work

 

dariobois
Resolver II
Resolver II

Hi!

Can you share us more information about the error?

damilola79
Frequent Visitor

 There is no error but it just doesnt work 

 

Set(
myLocation,
BingMaps.GetLocationByPoint(
Location.Latitude,
Location.Longitude
).name
);
ClockItFlow.Run(
User().FullName,
myLocation
);
UpdateContext({popup: true});
ClearCollect(
onClickHandler,
{
ClickEventDate: Now(),
User: User().Email
}
);
SaveData(
onClickHandler,
"onClickHandler"
)

@damilola79  Ok, so, is that your "OnSelect" button formula?

 

Share me the "DisplayMode" button property and OnStart App please.

 

Dario.

If(
Or(
DateDiff(
First(onClickHandler).ClickEventDate,
Now(),
Days
) >= 1,
IsEmpty(onClickHandler)
),
DisplayMode.Edit,
DisplayMode.Disabled
)

Hi @damilola79 ,

You are doing this to set the data

ClearCollect(
   onClickHandler,
   {
      ClickEventDate: Now(),
      User: User().Email
   }
)

This may be a bit of overkill, but I am trying to avoid potential errors

With(
   {
      wEvent:
      Lookup(
         onClickHandler,
         User=User().Email
      ).ClickEventDate
   },
   If(
      IsBlank(wEvent) 
      DisplayMode.Edit,
      If(
         DateDiff(
            wEvent,
            Now(),
            Days
         ) >= 1,
         DisplayMode.Edit,
         DisplayMode.Disabled
      )
   )
)

Note that this formula tests for a 24 hour difference. If you want just the next day, use Today() instead of Now().

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Hi @damilola79 ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thank You sir i tried it again today and it worked perfectly.

Once again thank you.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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