Field groups

A field group on a table is a way of grouping related fields together, to ease their presentation on a form or report.

Introduction
Field groups are specified under the Field Groups node for each table in the AOT. Several pre-defined field groups exist on every table, and new field groups can be added by a developer to new or existing tables.

The use of field groups is considered best practice. Forms designed using field groups will be automatically updated when new fields are added to the group on the table. If field groups are not used then the form design itself has to be updated when a new control is required.

Pre-defined field groups
The following field groups are pre-defined and exist on all tables. Not all of these groups will be present in all versions of Dynamics Ax:
 * AutoReport
 * AutoLookup
 * AutoIdentification
 * AutoSummary
 * AutoBrowse

Adding field groups programmatically
The following demonstrates how to add field group fields with code.



Sample code
TreeNode table, fieldGroups, fieldGroup, field;
 * AOT
 * 1) define.FieldGroups('Field Groups')
 * 2) define.TableFieldGroupItem('PROPERTIES\nTable\n#\%1\nDataField\n#\%2\nENDPROPERTIES')

// Gets the Address table. table = TreeNode::findNode(#TablesPath + #AOTDelimiter + tableStr(Address));

// Gets the Address table's Field Groups node. fieldGroups = table.AOTfindChild(#FieldGroups);

// Gets the 'Delivery' field group. fieldGroup = fieldGroups.AOTfindChild(tableFieldGroupStr(Address, Delivery));

// Adds the field 'Name' to the 'Delivery' field group. fieldGroup.AOTadd(fieldStr(Address, Name));

// Adds the display method 'tableRelationName' to the 'Delivery field group. // This uses the Address table's RecVersion field as a dummy and converts it // to a display field by setting its properties. field = fieldGroup.AOTadd(fieldStr(Address, RecVersion)); field.AOTSetProperties(strFmt( #TableFieldGroupItem, tableStr(Address), tablemethodstr(Address, tableRelationName)));

// Saves the changes to the table. table.AOTsave;

Applies to
Has been tested on Dynamics AX 2009 SP1 RU-6