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

To make the form button control enable disable using formComboBoxControl

(1) ShareShare
ReportReport
Posted on by 1,836
hi everyone,
 
I was trying to make the form button enable disable on the when i change the valuein form combo box control , i have make the code on event handler of salesquotation form but button is not getting disable ,can any one suggest what mistake i am doing .below is my code .
 
thanks,
Regards,
Dinesh
I have the same question (0)
  • Dineshkarlekar Profile Picture
    1,836 on at
     [FormDataSourceEventHandler(formDataSourceStr(SalesCreateQuotation, SalesQuotationTable), FormDataSourceEventType::Activated)]
        public static void SalesQuotationTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
        {
            #define.BTNNAME('DTCreateCustQuotation')
    
    
            FormRun form = sender.formRun();
            FormDataSource SalesQuotationTable_ds = form.dataSource(formDataSourceStr(SalesCreateQuotation , SalesQuotationTable)) as FormDataSource;
            SalesQuotationTable salesQuotationTable = SalesQuotationTable_ds.cursor();
            FormControl  createRetailCustbtn = form.design(0).controlName(#BTNNAME);
            FormComboBoxControl    accountType = form.design().controlName("AccountType");
    
            if(accountType.selectionChange() == smmQuotationAccountType::BusRelAccount)
           {
               createRetailCustbtn.enabled(false);
           }
            else if(accountType.selectionChange() == smmQuotationAccountType::CustAccount)
            {
                createRetailCustbtn.enabled(true);
            }
    
        }
    thanks,
    Regards,
    Dinesh
  • Layan Jwei Profile Picture
    8,097 Super User 2025 Season 2 on at
    Hi Dinesh,
     
    Did you debug first to see if it enters your code or not? and if it reaches the line enabled(false)?
     
    Debugging can sometimes answer the question.
     
    And it seems you want to disable the button if accountType is changed, then why you didn't use modified method instead of active?
     
    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at
    Please tell us more about the problem.
     
    What did you find when you debugged your code? e. Does it execute when you want (I see you don't execute it when changing the value of AccountTyp) and does it behave as expected?

    A hint: are you sure that selectionChange() method gives you what you want. Test it...
  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at
    Note that your code for accessing the controls is wrong. Never hard-code names of applications objects, because it's then not checked by the compiler and you won't find references for it. Using a macro doesn't solve this problem. You can use formControlStr(), but an easier approach is using a CoC extension and referring to the controls just by name (e.g. element.AccountType).
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
    thanks for reply ,
    i am using the right event handler ,if it is not correct which event handler i should use .please suggest.
     
     
    thanks,
    Regards,
    Dinesh
  • Layan Jwei Profile Picture
    8,097 Super User 2025 Season 2 on at
    Hi Dinesh,
     
    You didn't answer our question about what did you find when debugging.
     
    And I already suggested to do that on the modified method instead of active.
     
    So you can choose the modified event handler for the accountType or CoC for the modified method of the accountType... I prefer CoC.
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
    i debugged the code , when the form opens the button get disabled as it opens on first condition in event handler but when i make changes in combox control value , the dubugger does not hit . so i will try it with modified event .
     
    thanks ,
    Regards,
    Dinesh
  • Suggested answer
    Layan Jwei Profile Picture
    8,097 Super User 2025 Season 2 on at
    Hi Dinesh,
     
    You will need to add the code on both init method of the form and modified method of the control/form datasource field.
     
    Init method, so that if the account type matches the condition when you first open the form. And modified method when you actually modify the accountType value.
     
    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi Dinesh,
     
    Try to put your code on the active method if you want to enable/ disable the button when you open the form and on the modified method for the combo box that you mentioned.
     
     
    Thanks,
    Waed Ayyad.

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 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans