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 / Button should get disa...
Power Apps
Unanswered

Button should get disabled when clicked once

(0) ShareShare
ReportReport
Posted on by 531

I have a powerapp Send Email button which should disable once its clicked once. Next time if user access the app, button should be disabled as its clicked once already.

 

I wrote below code

 

Send Email OnSelect

Set(SendEmailClicked,true);

 

Send Email Display Mode

If(SendEmailClicked,DisplayMode.Disabled,DisplayMode.Edit)

 

The Send Email button gets disabled once its clicked. However if i refresh the app, button gets again into Edit Mode. May i know how to avoid this?

 

Categories:
I have the same question (0)
  • Anchov Profile Picture
    1,986 on at

    All variables and collections are cleared when an app is refreshed. If you need data to be stored persistently across different sessions, you'll have to use a permanent data source like SharePoint, SQL, Dataverse, etc. There are several ways to set this up, and I'll provide a simple example using Sharepoint.

     

    1. Begin by creating a SharePoint list named "Email Log." While you only need one column, you can add more if necessary. In this example, we will use the Title field to store the email addresses of the individuals clicking the button.

    Anchov_0-1699467928949.png

    2. Connect the newly created SharePoint list as a data source, and in the App > OnStart event, add the following formula:

     

    ClearCollect(colSentEmail, Filter('Email Log', Title = User().Email))

     

    3. Then, on your Send Email Button, OnSelect property, add the following code after your send email event:

     

    Patch('Email Log', Defaults('Email Log'), {Title: User().Email});
    ClearCollect(colSentEmail, Filter('Email Log', Title = User().Email))

     

    4. Finally, on the DisplayMode property of your send email button add this formula:

     

    If(CountRows(colSentEmail) = 0, DisplayMode.Edit, DisplayMode.Disabled)

     

    When a user clicks the "Send Email" button once, it is logged in the SharePoint list. The app checks this list for the log entry each time the app is launched to determine if the logged-in user has clicked the button before.

    Anchov_1-1699468581654.png

    Anchov_5-1699468795385.png

     

     


    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

    Cheers!
    Rick Hurt

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard