Tuesday, 19 May 2015

How to use Reference Group in a form in AX

How to use Reference Group in a form in AX

Ø  Reference Group control of a form will show the User needed fields like Name or any other specific field instead of a RecId but will save only RecId upon user selection in the backend. To use this Feature we need to use Replacement Key of a Table.
Ø  Index Specified in Replacement key of a table will be shown instead of RecId in the form. Following Example will briefly explain the creating and use of Replacement Key and Reference Group Field Control of a Form.
Ø  Important: This concept will only work upon having the table relations with RecId, as it’s a MS Design Framework.

v  Create two tables

  • Parent_Table
  •  Child_Table

v  Create three fields in Parent_Table

  •     AccNo(String)
  •    Name(String)
  •  Phone(String)
o    Create an index in Parent_Table
AllowDuplicates :NO
Alternatekey      :Yes
o    Drag drop name field of Parent_Table into NameIdx index.

o    Parent_Table
                  Replacementkey    : NameIdx

v  Create Three fields in Child_Table

  • Name(Int64)
  •  Address(String)
  •  ZipCode(String)

o    Create a relation between Name field of Child_Table and RecId of Parent_Table.
Relations of two Tables:

Set field                : Name
Set RelatedField :

v  Create a form

  •   ReferenceGroupForm
o    Add Parent_Table and Child_Table to datasource of form.

o    Select join source fo child datasource and set it to Parent_Table.

o    Create 2 grids (for parent_Table and Child_Table)
o    Set Grid1 datasource : Parent_Table
o    Set Grid2 datasource: Child_Table

  •     Add fields of Parent_Table data source to grid1.
  •    Add fields of  Child_Table data source to grid2.

NOTE: While creating referecegroup, use Int64 datatype for that field which is used. Because we need to create a relation between a field of child_table(Name) and parent_table(RecId). We know that RecId is Int64 type. Reference Group concept will only work on RecIds.

OUTPUT:  As we can see in form now, top grid is containing data from parent table and below grid
is containing data from child table. When we create new record in child table it will show all the

name record from parent table instead of RecId(Related field). But in  backend(Child_Table) it will save the recId of Parent_Table.

  • Now, In picture it is clear how the value coming in front end (form) and save in backend (table)