Bearbeiten

Freigeben über


Field groups (DropDown controls)

A field group in table or table extension objects defines the fields to display in a drop-down control on pages that use the table.

In a table object, you define field groups by first adding a fieldgroups control, and then adding one or more fieldgroup(<Name>; <Field>) keyword for each group, where:

  • <Name> can be either DropDown, for adding fields to the drop-down control, or Brick to display data as tiles.
  • <Field> is a comma-separated list of the fields, by name, to include in the group.

Note

A field group can also be used to specify fields that display when list type pages are shown in the tile view. For more information, see Displaying Data as Tiles.

fieldgroups
{
  fieldgroup(DropDown; Field1, Field2)
  {
        
  }
  fieldgroup(Brick; Field1, Field2)
  {
        
  }
}

Note

The fieldgroups keyword cannot be inserted before the key control.

Important

The syntax for using a DropDown, must be exactly DropDown with the right capitalization.

In a table extension object, the fieldgroups control allows you to add more fields to a field group defined for the table object. This can be done by using the addlast(<name>; <field>) keyword.

Warning

The server will remove the duplicates, if multiple extensions attempt to add the same field more than once. A field can only be added to the field group once.

Add fields for a drop-down control

You add a field to include in a drop-down control by using the DropDown field group name in the keyword.

The following example illustrates how to add the field

tableextension 50100 CustomerExercise extends Customer
{
    fields
    {
        field(50100; "V02Max"; Decimal) { }
    }
   
    fieldgroups
    {
        addlast(DropDown; V02Max) { }
    }
}

Note

If the field you're adding to the DropDown has Visibility = false on the underlying lookup page, it will not show up in the DropDown.

For example, if we want to add the "Address 2" field to the Ship-to Address DropDown, the following code illustrates the changes needed to add the "Address 2" field to the Ship-To Address DropDown fieldgroup. The underlying lookup page is the Ship-To Address List, where Address 2 has the Visibility property set to false.

tableextension 50101 ShipToAddressExercise extends "Ship-to Address"
{
    fieldgroups
    {
        addlast(DropDown; "Address 2"){}
    }
}

pageextension 50101 ShipToAddressExercise extends "Ship-to Address"
{
    layout
    {
        modify("Address 2")
        {
            Visible = true;
        }
    }
}

Adding new field groups

APPLIES TO: Business Central 2023 release wave 2 (version 23) and later

It's always possible to add fields to the two predefined field groups, DropDown and Brick. If they aren't defined on the target table, they'll be dynamically created and will contain only the fields specified in the addlast controls.

The ordering of the fields will then be determined by the order in which extensions are loaded by the server, while removing any duplicate fields.

See Also

Debugging in AL
Developing Extensions
Microsoft .NET Interoperability from AL