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

Announcements

News and Announcements icon
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 601

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 914

#2
11manish Profile Picture

11manish 627

#3
Valantis Profile Picture

Valantis 598

Last 30 days Overall leaderboard