Tuesday, March 10, 2020

Form Methods by COC Extension in D365

Form Datasource Method in Extension

[ExtensionOf(formDataSourceStr(LogisticsElectronicAddress,LogisticsElectronicAddress))]
final class CustomLogisticsElectronicAddressform_Extenison
{
public void modified()
    {
          FormDataObject fdo = any2Object(this) as FormDataObject;
          FormDataSource fds = fdo.datasource();
          LogisticsElectronicAddress logisticsElectronicAddress = fds.formRun().dataSource(formDataSourceStr(smmOutlookMyContacts,LogisticsElectronicAddress)).cursor();

/// In other way we can get form datasource value by as below
/// FormDataSource  logisticsElectronicAddress_DS = element.logisticsElectronicAddress_DS  as FormDataSource  

          next modified();

          logisticsElectronicAddress.enableFields();
    }
}

Form Datasource Field Method in Extension

[ExtensionOf(formDataFieldStr(InventJournalCount,JAD_InventJournalTrans,FailureReasonId))]
final class JADInventJournalCountJAD_InventJournalTransDSField_Extension
{
    public void modified()
    {
        FormDataObject fdo = any2Object(this) as FormDataObject;
        FormDataSource fds = fdo.datasource();
        JAD_InventJournalTrans jAD_InventJournalTrans = fds.formRun().dataSource(formDataSourceStr(InventJournalCount,JAD_InventJournalTrans)).cursor();
        InventJournalTrans  inventJournalTrans = fds.formRun().dataSource(formDataSourceStr(InventJournalCount,InventJournalTrans)).cursor();

        next Modified();
            
 jAD_InventJournalTrans.Description =  JAD_WarehouseFailureReason::find(jAD_InventJournalTrans.FailureReasonId, JAD_WarehouseFailureReasonType::Counting).Description;
 jAD_InventJournalTrans.InventJournalTrans = inventJournalTrans.RecId;
    }

}

No comments:

Post a Comment