Axaptapedia is now maintained by AgileCadence For more information please click here.

Field groups

From Axaptapedia
Jump to: navigation, search

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

Introduction[edit]

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[edit]

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:

Adding field groups programmatically[edit]

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

Before

Sample code[edit]

<xpp>

  1. AOT
  2. define.FieldGroups('Field Groups')
  3. define.TableFieldGroupItem('PROPERTIES\nTable\n#\%1\nDataField\n#\%2\nENDPROPERTIES')

TreeNode table, fieldGroups, fieldGroup, field;

// 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(); </xpp>

Applies to[edit]

Has been tested on Dynamics AX 2009 SP1 RU-6