Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

How to enable/ disable parameter using UIbuilder class.

Posted on by 1,457
 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 .
  • Layan Jwei Profile Picture
    Layan Jwei 7,347 Super User 2024 Season 2 on at
    How to enable/ disable parameter using UIbuilder class.
    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
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    How to enable/ disable parameter using UIbuilder class.
    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 , 

     
  • Verified answer
    Layan Jwei Profile Picture
    Layan Jwei 7,347 Super User 2024 Season 2 on at
    How to enable/ disable parameter using UIbuilder class.
    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
    Dineshkarlekar 1,457 on at
    How to enable/ disable parameter using UIbuilder class.
    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
    Layan Jwei 7,347 Super User 2024 Season 2 on at
    How to enable/ disable parameter using UIbuilder class.
    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
    Dineshkarlekar 1,457 on at
    How to enable/ disable parameter using UIbuilder class.
    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 
     
  • Layan Jwei Profile Picture
    Layan Jwei 7,347 Super User 2024 Season 2 on at
    How to enable/ disable parameter using UIbuilder class.
    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
    Dineshkarlekar 1,457 on at
    How to enable/ disable parameter using UIbuilder class.
    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);
            }
       
        }
    
    }
     
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,347 Super User 2024 Season 2 on at
    How to enable/ disable parameter using UIbuilder class.
    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
    Dineshkarlekar 1,457 on at
    How to enable/ disable parameter using UIbuilder class.
    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans