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

Report
All responses (
Answers (