Skip to main content

Notifications

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

Field enable/disable using check box in d365 form

(0) ShareShare
ReportReport
Posted on by 1,479

I have added one check box in my form and if i tick that check box there are two fields on another form that must be disable and if i enable how can i get this done . 

should i have to use chain of comand or i go with event handler of that checkbox. plz guide me on this.  

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Field enable/disable using check box in d365 form

    No need to change anything. Code you have written is correct.

    Thanks,

    Girish S.

  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 on at
    RE: Field enable/disable using check box in d365 form

    yes it is working , element.args().record()  is getting the record . current code is below do i need to change anything .

     [ExtensionOf(formDataSourceStr(TransTaxInformation,TransTaxInformation))]
     final class dtGeneralLedgerChKBx_Extension
    {
        public int active()
        {
            int ret;
           
            TransTaxInformation transTaxInformation;
            LedgerJournalTrans ledgerJournalTrans;
            ret = next active();
    
            ledgerJournalTrans = element.args().record();
           
            if(ledgerJournalTrans.ChkBox==NoYes::Yes)
            {
                FormDataSource fds = element.datasource(formDatasourcestr(TransTaxInformation, transTaxInformation));
               
                fds.object(fieldNum(TransTaxInformation, HSNCodeTable)).allowEdit(false);
                fds.object(fieldNum(TransTaxInformation, ServiceAccountingCodeTable)).allowEdit(false);
            }
            else
            {
                FormDataSource fds = element.datasource(formDatasourcestr(TransTaxInformation, transTaxInformation));
               
                fds.object(fieldNum(TransTaxInformation, HSNCodeTable)).allowEdit(true);
                fds.object(fieldNum(TransTaxInformation, ServiceAccountingCodeTable)).allowEdit(true);
            }
    
            return ret;    
       }
    
    }

    thanks

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Field enable/disable using check box in d365 form

    What is your issue? Is the element.args().record() returns anything?

    Is the functionality working.

    As I said earlier cursor method will return current record which is TransTaxInformation.

    Thanks,

    Girish S.

  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 on at
    RE: Field enable/disable using check box in d365 form

    hi ,

    mohit,

    so then where should i write this,cursor.

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Field enable/disable using check box in d365 form

    Problem is line#9, this.cursor will return TransTaxInformation and not LedgerJournalTrans table.

  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 on at
    RE: Field enable/disable using check box in d365 form

    i  have made changes in code and added this.cursor() but the form is giving error.

    [ExtensionOf(formDataSourceStr(TransTaxInformation,TransTaxInformation))]
     final class dtGeneralLedgerChKBx_Extension
    {
        public int active()
        {
            int ret;
           
            TransTaxInformation transTaxInformation;
            LedgerJournalTrans ledgerJournalTrans = this.cursor();
            ret = next active();
    
            ledgerJournalTrans = element.args().record();
           
            if(ledgerJournalTrans.ChkBox==NoYes::Yes)
            {
                FormDataSource fds = element.datasource(formDatasourcestr(TransTaxInformation, transTaxInformation));
               
                fds.object(fieldNum(TransTaxInformation, HSNCodeTable)).allowEdit(false);
                fds.object(fieldNum(TransTaxInformation, ServiceAccountingCodeTable)).allowEdit(false);
            }
            else
            {
                FormDataSource fds = element.datasource(formDatasourcestr(TransTaxInformation, transTaxInformation));
               
                fds.object(fieldNum(TransTaxInformation, HSNCodeTable)).allowEdit(true);
                fds.object(fieldNum(TransTaxInformation, ServiceAccountingCodeTable)).allowEdit(true);
            }
    
            return ret;    
       }
    
    }

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Field enable/disable using check box in d365 form

    this.Cursor will return the current record in the DataSource - In your scenario you won't get LedgerJournalTrans as a current record, since the form TransTaxInfomation doesn't have LedgerJournalTrans as a DataSource.

    Thanks,

    Girish S.

  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 on at
    RE: Field enable/disable using check box in d365 form

    hi  mohit ,

    thanks for reply,

    Replace Line# 8, with below code

    LedgerJournalTrans    ledgerJournalTrans = this.cursor(); 

    does this get current record, my current code is below.

    [ExtensionOf(formDataSourceStr(TransTaxInformation,TransTaxInformation))]
     final class dtGeneralLedgerChKBx_Extension
    {
        public int active()
        {
            int ret;
           
            TransTaxInformation transTaxInformation;
            LedgerJournalTrans ledgerJournalTrans;
            ret = next active();
    
            ledgerJournalTrans = element.args().record();
           
            if(ledgerJournalTrans.ChkBox==NoYes::Yes)
            {
                FormDataSource fds = element.datasource(formDatasourcestr(TransTaxInformation, transTaxInformation));
               
                fds.object(fieldNum(TransTaxInformation, HSNCodeTable)).allowEdit(false);
                fds.object(fieldNum(TransTaxInformation, ServiceAccountingCodeTable)).allowEdit(false);
            }
            else
            {
                FormDataSource fds = element.datasource(formDatasourcestr(TransTaxInformation, transTaxInformation));
               
                fds.object(fieldNum(TransTaxInformation, HSNCodeTable)).allowEdit(true);
                fds.object(fieldNum(TransTaxInformation, ServiceAccountingCodeTable)).allowEdit(true);
            }
    
            return ret;    
       }
    
    }
     

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Field enable/disable using check box in d365 form

    I think you need to use the element keyword to get the current record and assign to buffer and later assign the value to buffer.

    [ExtensionOf(formDataSourceStr(LedgerJournalTransDaily, LedgerJournalTrans))]
     final class LedgerJournalTransChkBX_Extension 
    {
        void initValue()
        {
           
            next initValue();
            LedgerJournalTrans    ledgerJournalTrans;
            ledgerJOurnalTrans = element.LedgerJournalTrans;
            ledgerJournalTrans.ChkBox = NoYes::No;
        }
    
    }

    Thanks,

    Girish S.

  • Verified answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Field enable/disable using check box in d365 form

    Replace Line# 8, with below code

    LedgerJournalTrans    ledgerJournalTrans = this.cursor();

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans