UIBuider in SysOperation framework in D365 F&O

Long Answer
Views 179

Answer:

UIBuider in SysOperation framework in D365 F&O

UIBuider: This class is only required when you want to play with added parameters (data member attributes) in the contract class. For example, modifying lookup or enabling/disabling certain parameters on a dialog.

In the VS project , create a new class called CustBalanceUIBuilder with the following code snippet:


class CustBalanceUIBuilder extends SysOperationAutomaticUIBuilder 
{ 
   DialogField     dialogFieldAllowModifyDate; 
   DialogField     dialogFieldTransDate; 
 
   CustBalanceDataContract custBalanceDataContract; 
 
   public boolean allowModifyDateModified(FormCheckBoxControl   
    _checkBoxControl) 
    {   
       // set enabled or disabled based on checkbox 
       dialogFieldTransDate.enabled
        (any2enum(dialogFieldAllowModifyDate.value())); 
       // or alternatively 
       // 
       dialogFieldTransDate.enabled
        (_checkBoxControl.checked()); 
     
       return true; 
    } 
 
    public void postBuild() 
    { 
       ; 
       super(); 
 
       // get datacontract 
       custBalanceDataContract = this.dataContractObject(); 
 
       // get dialog fields 
       dialogFieldTransDate= this.bindInfo().getDialogField
        (custBalanceDataContract,methodstr  
         (custBalanceDataContract,parmTransDate));
      
       dialogFieldAllowModifyDate=
       this.bindInfo().getDialogField 
        (custBalanceDataContract, methodstr
         (custBalanceDataContract,parmAllowModifyDate));
 
       // register override methods 
       dialogFieldAllowModifyDate.registerOverrideMethod
       (methodstr(FormCheckBoxControl, modified),  
       methodstr(CustBalanceUIBuilder, 
       allowModifyDateModified), this); 
       dialogFieldTransDate.enabled
       (any2enum(dialogFieldAllowModifyDate.value())); 
    } 
}

Here, we override the postBuild method and get the two dialog fields. Taking it further, we register the allowModifyDateModified() on event modified of our dialogFieldAllowModifyDate control.

Finally, we need to create an action menu item as an entry point to execute the preceding code:

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of X++ Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.