Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Disable new button based on save button (system generated default button)

(0) ShareShare
ReportReport
Posted on by 97

Hi All,

I am having one requirement that I need to disable the new button after the save button is clicked. New and Save are standard system buttons in form.

Please guide me  where i have to write code.

pastedimage1679659525486v1.png

Thanks in advance.

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: Disable new button based on save button (system generated default button)

    Thanks Andrew for your reply.

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,160 Super User 2025 Season 1 on at
    RE: Disable new button based on save button (system generated default button)

    Hi JohnPaul,

    Is there any business impact in case a user by accident clicks twice on the new button? Sometimes, I also do that, but can delete the wrong record. If there is no business impact, why adding logic to change the standard behavior of the application?

    If you need to have a user creating one record at a time, you can consider developing a creation dialog instead, like the customer creation form, sales/purchase order creation dialog.

  • Verified answer
    Andrew Xu Profile Picture
    Andrew Xu 3,877 on at
    RE: Disable new button based on save button (system generated default button)

    Hi PJ,

    You can make it work by overwriting write() method of your data source.

    Clicking button Save will call that method, and you can set 'allowCreate' to false to make button New disabled.

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Disable new button based on save button (system generated default button)

    Your requirement is still not clear, generally on click of New button, one record is created. Even if you disable New button and enable it on click of Save button, user still can create multiple records. How are you going to restrict it?

  • Suggested answer
    Komi Siabi Profile Picture
    Komi Siabi 12,759 Most Valuable Professional on at
    RE: Disable new button based on save button (system generated default button)

    JohnPaul,

    Tell us the document where the record is being created.

    Does the document have workflow enabled?

    Does the requirement say, a Maximum of one record per user on the table?

    If yes, you might consider indexes and disallow duplicate.

    Disabling the "New" button to stop multiple record is not an ideal design.

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Disable new button based on save button (system generated default button)

    Normally when you click on save button validateWrite method will be called and it will validate the current record and if it's an error it won't allow you to create a next new record otherwise it will allow you create new record.

    This is how it will work.

    If you want the user to won't allow to create next record without giving proper value on the current record you need to add validation for that. Trying to enable and disable a new button is not a good idea, I guess.

    Whatever you are trying to achieve is not possible, I think.

    Thanks,

    Girish S.

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: Disable new button based on save button (system generated default button)

    Hi Mohit,

    Thanks for your response.

    Now its allowing the user to create multiple records,

    we need to restrict that

    For that reason we want to disable new button after save button clicked we can enable the new button again

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: Disable new button based on save button (system generated default button)

    Hi Girish,

    Thanks for the response.

    Actually what i want is after clicking new button,it should get disabled.

    When the user click on save button at the time only new button should get enabled.

    After saving record only ,user should able to click the new button,until the record is saved,user should not able to click on new button

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Disable new button based on save button (system generated default button)

    Hi, May I know why do you need to disable the New button. It's a standard functionality to create new records after saving current record. You can check Customer groups form.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Disable new button based on save button (system generated default button)

    HI,

    If you hide the new button after saving it won't be available for next record creation. I mean it will be disabled all the time until you open and closes the form.

    Can you elaborate what you want to achieve?

    Thanks,

    Girish S.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans