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 :
Finance | Project Operations, Human Resources, ...
Unanswered

CoC and event handler explanation

(0) ShareShare
ReportReport
Posted on by 1,098

Hi team,

 

Requirement - Initialized the value in Custgroup while creating a record in CustTable

 

CoC on Insert method -

 

[ExtensionOf(tableStr(CustTable))]
final class CustTable_Extension
{
   public void insert()
   {
       this.CustGroup = 'RETAIL';

       next insert();
   }
}

 

Table event - Oninserting 

 

[DataEventHandler(
   tableStr(CustTable),
   DataEventType::Inserting)]
public static void CustTable_onInserting(
   Common sender,
   DataEventArgs e)
{
   CustTable custTable = sender as CustTable;

   custTable.CustGroup = 'RETAIL';
}

 

As per my assumption, For this particular requirement, the end result can be the same. Both can set CustGroup before the record is inserted.

 

But the important thing is

 

In CoC - We extending the method.

 

In Event handlers - Here wr responding to an event, not wrapping or extending the insert() method.

The MS recommended to use CoC instead of Event handlers. Whenever possible.

 

Am I correct?

 

Pls advise thanks 

Categories:

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 August Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 528 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
CU10121822-0 Profile Picture

CU10121822-0 374

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans