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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Update Form Design through CheckBox / Radio Button

(0) ShareShare
ReportReport
Posted on by 55

Inside the LederTransAccount form, we want to add a control (for example, a CheckBox or a Radio Button) that allows users to hide or unhide certain grid fields. I.e., if the checkbox is unmarked, the form would appear as default (standard D365 fields), if the checkbox was marked, the form would refresh and exhibit the default fields + some other custom fields inside the grid (doing it this way since the field is a Display Method, therefore, users can't simply use the "Add Columns" option).

In order to this, I extended the form and created the custom field on the grid (Field123) and the checkbox (CheckBox123), with the caption "Show Form with Field123".

My issue now is what I actually need to do to connect both the checkbox and the form refresh process and what logic should I write in the backstage (even more given the fact that this an extension, blocking me from adding custom methods directly into the form controls).

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    236,534 Most Valuable Professional on at
    RE: Update Form Design through CheckBox / Radio Button

    It sounds easy. You can use visible() method of the Field123 to show or hide it. For example:

    Field123.visible(false);

    And you can use checked() method of the checkbox to get the selection. When you combine it, Field123 will be visible when CheckBox123 is checked:

    Field123.visible(CheckBox123.checked());

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Update Form Design through CheckBox / Radio Button

    Hi joaoasilva11,

    You can create a CoC on the modified method of the form control and write your code there. You can check this link for details on CoC.

  • joaoasilva11 Profile Picture
    55 on at
    RE: Update Form Design through CheckBox / Radio Button

    It does sound easy, from multiple examples I saw inside D365 and "in my head", I completly understand the logic benhind what I should do. My issue is how? For example, I add the checkbox, I add the field, but how do I actually add the code given that I can't rewrite any logic in the extension form?

    I thought about event handlers or form adapters, but I don't know "where to begin".

  • Martin Dráb Profile Picture
    236,534 Most Valuable Professional on at
    RE: Update Form Design through CheckBox / Radio Button

    Use either CoC (Ganujan's answer) or event handlers.

    Form adapters have nothing to do with your requirement.

  • joaoasilva11 Profile Picture
    55 on at
    RE: Update Form Design through CheckBox / Radio Button

    Gunjan Bhattachayya provided a link that helped me understand (more or less) the CoC required to implement this. Your advice sounded simple as well, but I don't understand what "modified method of the form control" means. It's still a bit confusing to me since I don't know whether I should create a class or use an existing one (though none of them are in the same model as my project is so I can't use them). Even if I create a class, how does it correlate with what's happening in the form?

  • Martin Dráb Profile Picture
    236,534 Most Valuable Professional on at
    RE: Update Form Design through CheckBox / Radio Button

    You want to do something when a value of the form control (the checkbox) changes. Form control has modified() method for this purpose, therefore if you want to CoC, you need to create an extension (= a class) of the form control, override modified() method and add you extra logic there. For example:

    [ExtensionOf(formControlStr(MyForm, MyCheckbox))]
    final class MyForm_MyCheckbox_Extension
    {
        public void modified()
    	{
    	    next modified();
    	
            info("Hurrah!");
        }
    }

    Alterntively, you could expand the Events node of the control, select an event, copy an event handler method (use contect menu) and paste it to any class.

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Update Form Design through CheckBox / Radio Button

    Hi joaoasilva11,

    You can think what you would be doing had this been a custom form you designed. You would have created a checkbox field and overridden modified method in the control and placed your logic there. A simple example of this would be AllOpenPostedField control in LedgerJournalTable form. The records in the form get filtered as per the selection of this control.

    Since your form is a standard one, you can't add new methods to this control. This is where CoC helps you. You can add a new class that will extend the new control from LederTransAccount form.  You can then add modified method in this class, which will be equivalent to overriding modified method to the form control. Your class will look like this

    [ExtensionOf(formControlStr(LederTransAccount, CheckBox1))]
    final class LederTransAccount_ChkBox1_Extension
    {
        public void modified()
        {
            next modified();
            //Your logic goes here
        }
    }

  • joaoasilva11 Profile Picture
    55 on at
    RE: Update Form Design through CheckBox / Radio Button

    I took into account what was said earlier and tried to develop a brief draft of what the CoC function should be. This is what I came up with:

    pastedimage1647015499844v1.png

    It is returning some errors. Am I going on the right path here or is it completly wrong?

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Update Form Design through CheckBox / Radio Button

    Hi joaoasilva11,

    Which grid fields do you want to hide/show using this button?

  • joaoasilva11 Profile Picture
    55 on at
    RE: Update Form Design through CheckBox / Radio Button

    Hi Gunjan Bhattachayya, I updated my past reply with another code draft.

    Answering your question, I want to update the "FCMReversed" field. If the checkbox is active, then FCMReversed should appear. If it's inactive, then it shouldn't be visible.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,850

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 519 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans