where we can use coc
chain of command can be used in the following objects
1.Classes
2.Tables
3.Forms
4.Datasource on a form.
5.Data field on a form.
6.Control of a form.
7.Data entities
step1:name of the chain of command class we create must end with the _Extension.
step2:The keyword ‘final’ must be used in the class definition line.
step3: The class needs to have the attribute
[ExtensionOf(classStr(<NameOfBaseObject>))]
The “classStr” text above will change depending on the type of base objecting you are extending.
-> Below are the extensions used based on where we are using chain of commands.
-> When extending a class, use classStr(<NameofBaseClass>)
-> When extending a table, use tableStr(<NameOfBaseTable>)
-> In the case of a form, use formStr(<NameOfBaseForm>)
-> When extending a form Datasource use formDataSourceStr(<NameOfBaseForm>,<NameOfDataSource>)
-> When extending a form Data field, use formDataFieldStr(<NameOfBaseForm>,<NameOfDataSource>,<NameOfField>)
-> For a form control, use formControlStr(<NameOfBaseForm>,<NameOfControl>)
-> When extending a data entity, use tableStr(<NameOfBaseDataEntity>)
step4: our code must call the base class’s method inside our extension method using the ‘next’ keyword.we need to have this line.
var s = next doSomething(arg);
** Example for form extension called SalesTable
[ExtensionOf(formStr(SalesTable))]
final class SalesTable_Form_Extension
{
public void init()
{
next init();
//customize code goes here
}
}
Conclusion:
1)we can use Chain Of Command to add additional code before or after the call to the base method.
2)we still always have to call the base method. But we can change how the method works.
****Important point
3)By adding code after the call to the base method, we can add additional validation, functionality,and actions that should occur anytime the method is called.
Comments
Post a Comment