Saturday, December 10, 2022

Form Level COC syntax

 Useful COC syntax

1. Form level
2. Form Datasource level
3. Form DataField level
4. Form Control level

Form level CoC:

When extending a form, use formStr(<FormName>)

 Get Buffers:  

FormRun               formRun             =  this as  FormRun;
FormDataSource  dataSource_ds    =  formRun.datasource(FormDatasourceStr(FormName,DatasourceName));
TableName             tableName         =  dataSource_ds.Cursor();
FormControl          formControl      =  formRun.design().ControlName(FormControlStr(FormName,ControlName));

 Example:

[ExtensionOf(formStr(SalesTable))]
final class KSSalesTableFrm_Extension
{
    public int active()
    {
FormRun              formRun                  = this as  FormRun;


        //get any datasource from the base form
FormDataSource salesLine_ds            = formRun.datasource(FormDatasourceStr(SalesTable,SalesLine));  
SalesLine              salesLine                  = salesLine_ds.Cursor();

//get any formcontrol from the base form
FormControl      itemName= formRun.design().ControlName(FormControlStr(SalesTable, itemName));

//business Logic

 return next active();
      }
}

2. Form Datasource level CoC:

When extending a form Datasource, use formDataSourceStr(<FormName>, <DataSourceName>)

Example:

[ExtensionOf(formDatasourceStr(SalesTable, SalesLine))]
final class KSSalesTableFrm_SalesLineDS_Extension
{
    public void executeQuery()
    {
         next executeQuery();

        FormDataSource                  formDS                    = this;
        FormComboBoxControl      comboBoxControl;   

        //get form datasource       
        SalesLine             salesLineLocal  = this.cursor();               

//get any other datasource from the base form
        FormDataSource inventDim_ds  = formDS.formRun().dataSource(formDataSourceStr(SalesTable, InventDim));
        InventDim            inventDim      = inventDim_ds.cursor();

//get any formcontrol from the base form
        comboBoxControl     = formDS.formRun().design().controlName(formControlStr(SalesTable, SalesTable_SalesTypeGrid));

        //business logic
    }
}


3.  Form Datafield level CoC:

When extending a form Datasource Field, use formDataFieldStr(<FormName>, <DataSourceName>, <DataFieldName>)

Example:

[ExtensionOf(formDataFieldStr(SalesTable, SalesLine, BarCode))]
final class KSSalesTableFrm_SalesLineDS_BarCodeDF_Extension
{
    public void modified()
    {
         next modified();

         FormDataObject                    barCode_do = any2Object(this) as FormDataObject;
         FormComboBoxControl       comboBoxControl;        

         //get form datasource
        FormDataSource                 salesLine_ds   = barCode_do.datasource();
        SalesLine                              salesLine         salesLine_ds.cursor();

//get any other datasource from the base form
        InventDim    inventDim     = salesLine_ds.formRun().dataSource(formDataSourceStr(SalesTable, InventDim)).cursor();

//get any formcontrol from the base form
 comboBoxControl   = salesLine_ds.formRun().design().controlName(formControlStr(SalesTable, SalesTable_SalesTypeGrid));

        //business logic
      }
}


4.  Form DataControl level CoC:

When extending a form DataControl Field, use formDataControlStr(<FormName>, <ControlName>)

Example:

[ExtensionOf(formControlStr(SalesTable, PrintMgmt))]
final class KSSalesTableFrm_PrintMgmtCtl_Extension
{
    public void clicked()
    {

        FormControl                       buttonControl         any2Object(this) as FormControl;
        FormRun                             formRun                 buttonControl.formRun();
       
        InventDim                           inventDim
        FormComboBoxControl   formComboBoxControl;

//get any datasource from the base form
        inventDim     = formRun.dataSource(formDataSourceStr(SalesTable, InventDim)).cursor();

//get any formcontrol from the base form
 formComboBoxControl   = formRun.design().controlName(formControlStr(SalesTable, SalesTable_SalesTypeGrid));

        next clicked();
        //business logic
      }
}


No comments:

Post a Comment

Build Explained

Useful Blogs. https://axtechsolutions.blogspot.com/2018/08/performing-builds-in-d365.html https://community.dynamics.com/blogs/post/?postid=...