coc concept notes
what is COC?
ANS:
-> COC stands for chain of command.
-> CoC allows us to customize standard classes without using event handlers.
-> COC allows us to add custom logic that will run before and/or after the standard code runs.
-> We can only extend the logic of public and protected methods.
-> It is important to understand this concept, as base code cannot be changed in Dynamics 365 finance and operations apps development.
-> When no more methods exist in the chain, the original (in other words, extended) method is called.
[ExtensionOf(classStr(BusinessLogic1))] //name of the base class
final class BusinessLogic1_Extension //final keyword followed by class followed by baseobjectname _Extension
{
str doSomething(int arg)
{
// Part 1 // the logic which we write before next method will get execute first
//We are required to use the next keyword to create a CoC. The next command will call the next method in the Chain of Command
// Custom logic before standard code.
var s = next doSomething(arg);
// Custom logic after standard code.
return s;
}
}
Comments
Post a Comment