Add AX FormGroupControl runtime

Apparently you cannot populate a form data group runtime in AX. I have been able to overcome the issue by adding the controls dynamically. In this example I have created a form with InventTable as the datasource, and added a FormGroupControl called FormDataGroup with AutoDeclare = Yes. Then I have overridden the executeQuery() on InventTable_ds to call my custom method stored on the form. Here is the source to add AX FormGroupControl runtime from code:

 

DAXRunBase / 2016-09-21 / AX 2012
Tags: , , , ,

Comments

  1. Add AX FormGroupControl runtime - Microsoft Dynamics AX Community
  2. Visvash Walia - 2017-02-21 @ 06:56

    HI Vilmos,
    Thanks for posting this,
    I am try to do the same in my environment and successful to add formgroup control dynamically at runtime but Fields are growing multiple times when i refresh the form .
    For example , my fieldGroup has 3 fields so when i open form it has 3 fields in formGroupControl but when i refresh form (by F5 or some filter) then addtional same 3 fields are created means now form has 6 fields and so on ..
    Please suggest

    Reply
    • DAXRunBase - 2017-02-21 @ 10:25

      Declare a new global boolean variable in the form’s Classdeclaration like isFieldGroupAdded. By default, it will have false state. Put the dynamic field group logic in a code block like if (!isFieldGroupAdded) { … }, and at the end of the logic set isFieldGroupAdded = true;
      This way it will only fire your logic once.

      Reply

Leave a Reply

Your email address will not be published / Required fields are marked *