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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Override save button on form

(1) ShareShare
ReportReport
Posted on by 53
Hi,

How can I override Save button on PO form. Its system defined standard button.

Thank you
I have the same question (0)
  • GirishS Profile Picture
    27,827 Moderator on at
    Override save button on form
    Hi,
     
    What is the functionality you are doing?
    You cannot override the methods on save button - As you said it's a standard button - You can only write events for that.
    For example, when we click on save button validateWrite methods will be called.
    Please tell us the functionality you need so that we can give suggestion based on that.
     
    Thanks,
    Girish S.
  • Martin Dráb Profile Picture
    237,662 Most Valuable Professional on at
    Override save button on form
    Please explain what you're trying to do. You maybe be interested in validateWrite(), write(), insert()/update() or even something else.
     
    In general, don't focus on the button itself, but that's not the only way how to save a record. You can use a keyboard shortcut, close the form and so on. You likely want to do something when a record is being saved, regardless of how it was triggered. And maybe you want to run the same logic even if it's saved in other forms.
  • m Profile Picture
    53 on at
    Override save button on form
    The issue is the while calling Save button on PO form, it is calling PurchTable.write() too many times.
     
    Whereas, I want to trigger my code only one time when the PurchTable record is updated and not all the time.
  • Martin Dráb Profile Picture
    237,662 Most Valuable Professional on at
    Override save button on form
    Use the debugger to find out what code is responsible for the extra write() calls. You can't fix the problem without first finding out what's going on.
     
    Apart from the fact that the button isn't the only way how to save the record, you can't change the logic there anyway. What you need to do is looking for the actual cause.
  • Komi Siabi Profile Picture
    13,089 Most Valuable Professional on at
    Override save button on form
    Hello,
     
    Like Martin said, can you please tell us exactly what you are trying to achieve, where your code is being executed.
  • m Profile Picture
    53 on at
    Override save button on form
    I will appreciate if anyone can let me know how to change the logic of Save button and put my own.
     
    I would basically like to perform some action or method calling after the form Save has compeleted.

    Thanks
  • Martin Dráb Profile Picture
    237,662 Most Valuable Professional on at
    Override save button on form
    What you ask for "how to change the logic of Save button" is not what you want "method calling after the form Save has compeleted". As explained before, using a button is not the only way to save a record. If you put logic just on the button, you'd miss all the other cases (e.g. saving by a keyboard shortcut or switching to another record).
     
    As mentioned in first replies in this thread, the correct approach is overriding system methods (or handling events) that are called when a record is saved. Which one you should use depends on what exactly you want to achieve, e.g. whether it's logic specific to this single form or it should be called everywhere where the record is saved. Please explain the business requirements to us, so we can help you design a technical solution that is can actually do the job.
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    Override save button on form
    For your requirement like to call your code only when PurchTable is updated even though multiple calls to write,
    you need to write code in update method of PurchTable and also have to add a condition like if it is already having a value(from custom code) then not to update.
  • m Profile Picture
    53 on at
    Override save button on form
    is there a way to attach post eventhandler to systemdefinedsavebutton which is the standard Save button on the form?
     
    So after all update to datasources have been completed, i can trigger my code only then.
  • André Arnaud de Calavon Profile Picture
    300,714 Super User 2025 Season 2 on at
    Override save button on form
    Hi M,
     
    You are ignoring some comments and questions below. You keep asking about overriding of a system button. Martin mentioned several times that the button is not the only way to save a record. In 96% of the cases in Dynamics 365, leaving a record or closing the form will also automatically save the record. We would like to know what exactly needs to be achieved from a functional point of view. Then we can help you with a correct solution.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 400 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans