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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (46,175)