web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Disable and enable but...
Power Apps
Answered

Disable and enable button base on time and Click

(0) ShareShare
ReportReport
Posted on by 20

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.

Categories:
I have the same question (0)
  • dariobois Profile Picture
    195 on at

    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!

  • damilola79 Profile Picture
    20 on at

    Please it didnt work

     

  • dariobois Profile Picture
    195 on at

    Hi!

    Can you share us more information about the error?

  • damilola79 Profile Picture
    20 on at

     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"
    )

  • dariobois Profile Picture
    195 on at

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

     

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

     

    Dario.

  • damilola79 Profile Picture
    20 on at

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

  • Verified answer
    WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    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.

  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at

    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.

  • damilola79 Profile Picture
    20 on at

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

    Once again thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard