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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Suggested Answer

How to execute a custom X++ method directly after a customer is created or updated in Dynamics 365

(0) ShareShare
ReportReport
Posted on by 132

Question:

I need help with X++ in Dynamics 365 Finance and Operations. I want to execute custom code after a customer record is successfully saved, whether it is a new customer creation or an update to an existing customer.

For example, I have a custom method called RunTest() and I want it to be triggered automatically when the user enters customer information and clicks Save, but only after the record has been successfully written to the database.

 

I need the correct code, and I would appreciate it if you could provide me with an example. Thank you all.

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    239,452 Most Valuable Professional on at
    How do you define "the record has been successfully written to the database"? That the INSERT statement was executed in database? That the out-most transaction has been comitted? Or somehow else?
    It'll help if you explain your business scenario, so we understand the context of your question.
     
    The usual approach is extending insert() and update() method (or handling the corresponding events). This happens inside a transaction, but if the transaction gets rolled back, both the customer changes and changes done by your code will be rolled back together. It's not a suitable solution in all cases, though. For example, if you want to call send a notification to external system, doing that inside a transaction would be wrong for several reasons.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 138 Super User 2026 Season 1

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 91 Super User 2026 Season 1

#3
Zain Mehmood Profile Picture

Zain Mehmood 89 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans