web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to enable/ disable parameter using UIbuilder class.

(1) ShareShare
ReportReport
Posted on by 1,836
 HI,
i have created a batch job where i need to disable the parameter on selection of a parameter so i have created the UIbuilder class but the parameter is not getting disable , plz any  one guide me on this , my code is below .
I have the same question (0)
  • Dineshkarlekar Profile Picture
    1,836 on at
    final class DTPackingSlipNotInvoicedBatchUIBuilder extends SysOperationAutomaticUIBuilder
    {
        DialogField typeField;
        DialogField   toField;
    
          public void postBuild()
        {
            super();
        
            // get references to dialog controls after creation
            typeField = this.bindInfo().getDialogField(this.dataContractObject(),
                                        methodStr(DTPackingSlipNotInvoicedBatchContract, parmtype));
            toField = this.bindInfo().getDialogField(this.dataContractObject(),
                                        methodStr(DTPackingSlipNotInvoicedBatchContract, parmTo));
        }
    
        public void postRun()
        {
            super();
        
            // register overrides for form control events
            typeField.registerOverrideMethod(methodstr(FormComboBoxControl, modified),
                                             methodstr(DTPackingSlipNotInvoicedBatchUIBuilder, modified), this);
        }
    
        public boolean  modified(FormComboBoxControl   _selection)
        {
            boolean   toField;
    
            DTPackingSlipNotInvoicedBatchContract  cTPackingSlipNotInvoicedBatchContract = this.dataContractObject() as DTPackingSlipNotInvoicedBatchContract;
    
            if(_selection.selection() == DTPackingSlipNotInvoiceType::SalesPerson)
            {
                toField.visible(false);
            }
       
            return toField;
        }
    
    }
    thanks ,
    regards,
    dinesh.
  • Suggested answer
    Layan Jwei Profile Picture
    8,097 Super User 2025 Season 2 on at
    Hi Dinesh,

    it seems you are changing the boolean flag "toField", instead of disabling the dialogField "toField"

    So maybe try something like this,  and let us know (I'm not sure if the whole code is correct)
        public void  modified(FormComboBoxControl   _selection)
        {
            DTPackingSlipNotInvoicedBatchContract  cTPackingSlipNotInvoicedBatchContract = this.dataContractObject() as DTPackingSlipNotInvoicedBatchContract;
    
            if(_selection.selection() == DTPackingSlipNotInvoiceType::SalesPerson)
            {
                toField.enabled(false);
            }
        }

    Thanks,
    Layan Jweihan
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
    thanks for reply ,
     
    but its not working field is still eidtable , can you please i had made the changes 
    final class DTPackingSlipNotInvoicedBatchUIBuilder extends SysOperationAutomaticUIBuilder
    {
        DialogField typeField;
        DialogField   toField;
    
          public void postBuild()
        {
            super();
        
            // get references to dialog controls after creation
            typeField = this.bindInfo().getDialogField(this.dataContractObject(),
                                        methodStr(DTPackingSlipNotInvoicedBatchContract, parmtype));
            toField = this.bindInfo().getDialogField(this.dataContractObject(),
                                        methodStr(DTPackingSlipNotInvoicedBatchContract, parmTo));
        }
    
        public void postRun()
        {
            super();
        
            // register overrides for form control events
            typeField.registerOverrideMethod(methodstr(FormComboBoxControl, modified),
                                             methodstr(DTPackingSlipNotInvoicedBatchUIBuilder, modified), this);
        }
    
        public void modified(FormComboBoxControl   _selection)
        {
          
            DTPackingSlipNotInvoicedBatchContract  cTPackingSlipNotInvoicedBatchContract = this.dataContractObject() as DTPackingSlipNotInvoicedBatchContract;
    
            if(_selection.selection() == DTPackingSlipNotInvoiceType::SalesPerson)
            {
                toField.visible(false);
            }
       
        }
    
    }
     
  • Layan Jwei Profile Picture
    8,097 Super User 2025 Season 2 on at
    Hi Dinesh,
     
    Did you debug and see if the code reaches at least the modified method and maybe enters the if condition or not? Please check and get back to us.
     
    Thanks,
    Layan Jweihan
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
     i have debugged , no method is hitting on uibuilder class , i have change the parameter values but is is not getting into modify method 
     should i use allow edit () , enable () or visible() which should i use 
    thanks ,
    regards ,
    Dinesh 
     
  • Verified answer
    Layan Jwei Profile Picture
    8,097 Super User 2025 Season 2 on at
    Hi Dinesh,
     
    If no method is being hit with debugger in UI builder (postBuild..etc)
    Then maybe it's because you didn't define the UI builder as an attribute in the contract class.
     
      [DataContractAttribute,
       SysOperationContractProcessingAttribute
    (classStr(UIBuilderClassName))
    ]
    public class contractClassName
    {}
     
    Please try this and debug again and see what happens.
     
    Thanks,
    Layan Jweihan
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
    it is working , but is taking the default value of   sales when the dialog box open and the field is editable and when i change it to sales person again then it get non editable but when the form opens its is editable and default value is set to sales person that should not happen how can i change this , plz help me out on this .
            if(_selection.selection() == DTPackingSlipNotInvoiceType::SalesPerson)
  • Verified answer
    Layan Jwei Profile Picture
    8,097 Super User 2025 Season 2 on at
    Hi Dinesh,
     
    Does the postBuild gets called when dialog first opens? If yes maybe try to repeat the logic again in this method as well

    Maybe sth like this: (I'm not 100% sure of the syntax)

        public void postBuild()
        {
            super();
        
            // get references to dialog controls after creation
            typeField = this.bindInfo().getDialogField(this.dataContractObject(),
                                        methodStr(DTPackingSlipNotInvoicedBatchContract, parmtype));
            toField = this.bindInfo().getDialogField(this.dataContractObject(),
                                        methodStr(DTPackingSlipNotInvoicedBatchContract, parmTo));
      if(typeField.Value() == DTPackingSlipNotInvoiceType::SalesPerson)
      {
      toField.enabled(false);
      }
    }

     
    Thanks,
    Layan Jweihan
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
    thanks for reply ,
     
    its working now but  forms open with salesperson as default value which is second value and it showing some warning kind of sign on parameter , and when i click ok to process the batch job i am getting this error msg , 

     
  • Layan Jwei Profile Picture
    8,097 Super User 2025 Season 2 on at
    Hi Dinesh,

    If the last reply related to making the field disabled when you first open the dialog helped you, then please mark it as verified and post a new question for your new problem. So that we keep each question related to a certain topic.

    Thanks,
    Layan Jweihan

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans