Skip to main content

Notifications

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
  • m Profile Picture
    m 53 on at
    Override save button on form
    The requirement is simple i.e.
     
    The user needs to be notified whenever PurchTable is updated through PO form only.
     
    Thanks
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,969 Super User 2025 Season 1 on at
    Override save button on form
    HI M,
     
    When you want to send a notification to users, I think using the write() method on the PurchTable datasource is an incorrect choice. The purchase order header gets updated also by writing line details. The header status is getting updated based on the lowest status for all order lines. I would suggest having a look at extending the confirmation logic as that is triggered once and only when the user completed all his changes on the purchase order. If this is feasible for you or not, I don't know as you only mentioned that a notification should be sent, but not when. For me, this is not the full requirement as there is room for multiple interpretations about when notifications should be triggered. 
     
  • m Profile Picture
    m 53 on at
    Override save button on form
    any ideas how to achieve this i.e. on update of PurchTable, we need to send notifications to users
  • m Profile Picture
    m 53 on at
    Override save button on form
    I need to do send notifications to user.
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,969 Super User 2025 Season 1 on at
    Override save button on form
    Hi M,
     
    You only tell that you want to trigger your code, but not what this code should solve for a business user. Try to leave the technical thoughts and provide us with a functional description what should be the end result of your "trigger my code".
    Do you need to send an email? Do you need to update some fields in the purchase order or other tables? I do assume someone provided you functional requirements, correct? 
  • Martin Dráb Profile Picture
    Martin Dráb 230,842 Most Valuable Professional on at
    Override save button on form
    As discussed before, your design is completely wrong and it wouldn't solve your problem even if you could run your code in clicked() method of the button, because all the existing code would still execute. You're wasting time with this design. What you really need to do to solve your problem is analyzing why your code is executed several times.
     
    I suggest we abandon this thread (because this design shouldn't be followed) and you create a one. There you'll explain your business requirement (which should explain why you have in write(), or suggest that it's a wrong place), show us your code and provide call stacks of excessive calls. Then we should be able to help you with debugging and maybe spot bugs in your code.
     
     
     
  • m Profile Picture
    m 53 on at
    Override save button on form
    I already explained previously that on Save event of form whether through button click or shortcut, I would like trigger my code. This code only need to trigger only once. 
     
    Currently I have placed the code on write method of PurchTable datasource. It is triggerring correctly but it gets triggered too many times as PurchTable is getting updated 3-4 times within first call of update.

    Also I dont want it to be called at form close because I want the user to be notified of error if the my code results into user defined or system or any kind of error or exception.

    So based on this, pls let suggest what is the best approach i can take.
     
    Thanks
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,969 Super User 2025 Season 1 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.
  • m Profile Picture
    m 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.
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 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.

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…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,969 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,842 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans