CHAIN OF COMMAND/COC ON A TABLE METHOD IN D365
When we want
to change in the standard methods, and it cannot be easily achievable through
the Extension or even through the event handler approaches then in that case we
use the chain of command i.e., COC technique.
New
form:
First, create
a new form
by right-clicking on design and selecting new and then add all these controls
Now add
different fields that you want to manipulate, we added three different fields:
Customer Name, Account and Address in the grid with the following
properties.
Strings |
Data Source |
Data Method |
Data Field |
AccountNum |
CustTable |
|
AccountNum |
CustomerName |
CustTable |
name |
|
CustomerAddress |
CustTable |
address |
|
We choose DataMethod as the CustTable
does not contain these particular fields.
COC
class:
Now add a
new class with the suffix _Extension and tell in the first line that it
is the extension of which table. And the class should be Final.
Now add your
logic the keyword next is very significant here as the execution of the
code depends on the position of the code i.e., code is written pre- or post-the
next keyword.
Code:
final class RM_CustTable_Extension
{
display CustName name()
{
str CustomerName;
CustomerName = next name();
return CustomerName;
}
display logisticsaddressing address()
{
custAddress = 'Guru Group_' + custAddress;
return custAddress;
}
Set form as
the startup object and run the project.
Comments
Post a Comment