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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Used of exact place to use event handlers and CoC in D365FO

(0) ShareShare
ReportReport
Posted on by 744

Hi team,

Always i being confused to use of Event handlers and CoC. As both are worked like Pre and Post.

So, I did research and understood

 

Event handlers -

Suppose Microsoft has a standard CustTable.insert() method.

For example - Suppose, Whenever a new customer is created, I want to create an entry in my custom table.

So, here we are not trying to change how Microsoft creates the customer. Here we just want to react after the customer is created. So, I beleive Post event handlers are appropriate for this.

 

[PostHandlerFor(tableStr(CustTable), tableMethodStr(CustTable, insert))]
public static void CustTable_Post_insert(XppPrePostArgs args)
{
   CustTable custTable = args.getThis();

   // Insert record into custom audit table
}

 

CoC -

For example - When a new customer is created, I want to automatically set a default customer group before the standard insert() logic executes.
Here, we are extending the existing insert() method itself, so CoC i beleive  appropriate.

 

[ExtensionOf(tableStr(CustTable))]
final class CustTable_Extension
{
   public void insert()
   {
       // Custom logic
       if (!this.CustGroup)
       {
           this.CustGroup = "10";
       }

       // Execute Microsoft's standard insert logic
       next insert();
   }
}

Is ami correct?

Pls advise, thanks 

 

 

Categories:
I have the same question (0)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 270 Most Valuable Professional

#3
Anton Venter Profile Picture

Anton Venter 217 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans