Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Button should get disabled when clicked once

(0) ShareShare
ReportReport
Posted on by 494

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:
  • Anchov Profile Picture
    1,984 on at
    Re: Button should get disabled when clicked once

    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,522 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,890 Most Valuable Professional

Leaderboard