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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to disable the button after one press

(0) ShareShare
ReportReport
Posted on by 534

Hi Guys,

How to disable the button automatically,after the button is clicked once.

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    You can hook in the clicked method of the button. This way you can execute your code when the button is clicked.

    Code for disabling a button would look like:

    ButtonName.enabled(false);

    Please note that you need to set AutoDeclaration to Yes for your button so that you can easily refer it from your code.

  • WillWU Profile Picture
    22,361 on at

    Hi jenifer,

    What's your requirement?

    Just writing an event post handler may not be enough. Does the status of the form change? Do you need to press the button when you open the form again?

    If you need to determine the availability of the button based on states, you can code in the onactive() method of the data source.

  • Adam123 Profile Picture
    534 on at

    Example-

    I have "Submit" Button

    when I click the submit button , it should be submitted only once and then the submit button should be disabled.

    The button should be clicked once,not for the second time.

  • Verified answer
    WillWU Profile Picture
    22,361 on at

    Hi jenifer,

    If it is a custom form, you can add an enum field to the data source and write in onactive() method of the data source(Code provided by Nikolaos).

    You need to change the value of the enum in the button's onclick method and determine the availability of the button based on the value of the enum.

    Hope this helps.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    As Will WU wrote, you need to save information "Is this record submitted?" and use this information to enable/disable the button. Otherwise the button would be enabled if the user closed and reopens the form.

    So, here's the solution:

    1) Add boolean/checkbox field "Submitted" to your table

    2) When the submit process is done (NOT when the button is clicked but when the process is really done succesfully!) update "Submitted" field to "Yes"

    3) In Active method of your form data source, enable/disable the button based on the value of the Submitted field.

    4) Set property "Auto refresh data" to Yes in your Submit button. This will make sure that the button is disabled once the submit process is completed.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans