glyphox
How-to guides · 3 of 15Define a structure

Documentation / How-to guides

Define a structure

Define a named set of typed fields and use it as the type of a parameter, a variable or an action's return value.

Applies to Glyphox 1.0.10

Before you begin

  • A solution open in VS Code, with a module that holds logic.

A structure is a named set of typed fields, for example a CustomerSummary with a name, an email and a number of open tickets. It holds no data and no logic. Use a structure where an action takes or returns values that belong together and are not a record of a table.

Step 1: Create the structure

In the Solution tree, select New Structure beside the module's Structures group, or run Glyphox: New Structure. Enter a name. The structure opens in the structure editor, where you can also enter a description.

You can also create a structure at the moment you need one. Wherever a type is selected, the list shows the types under Basic, Tables and Structures, and ends with New Structure…, which creates the structure and selects it.

Step 2: Add its fields

Select Add Field and set the field's name and its Type: a basic type, a table or another structure. Select List for a field that holds several values, and Required for a field that must have a value. The arrows on a row change the order of the fields.

Add Fields from Table… adds fields from the columns of a table. Select the table and the columns, then select the button that states how many fields are added, such as Add 3 Fields. Each field takes the name and the type of its column. A column that is already a field is marked Already a field and cannot be selected.

Step 3: Use it as a type

Open an action and, in its Properties, select the structure as the type of an input parameter, an output parameter, a local variable or the return value. A variable of the module, and a variable or a parameter of a page, can have a structure as its type in the same way.

Step 4: Set its fields in an action

Add an Assign step. Under Set a structure, select a variable whose type is a structure. The step lists the structure's fields, with one expression for each. A field that has the same name as a column of a record in scope is filled in for you.

An expression reads a field by name after the variable, such as {{summary.Email}}.

Structures and other modules

A structure has no Public switch. A module that references this one receives the structures that this module's public actions use, and can use them as types. They are read-only there: the Solution tree lists them under the module's References, and they are changed in the module that owns them.

A public action whose parameter or return value is a record of a table requires that table to be public. A public action that returns a structure does not, so a structure lets a module share a result without making its table public.

Rename and delete

Renaming a structure or a field updates everything that uses it: the types of parameters, variables and return values, the fields of other structures, the expressions that read a field and the Assign steps that set one, including in the modules that reference this one. A use that cannot be updated is named before the rename.

The editor shows beside the structure's name where it is used. Delete structure names what uses the structure before it is deleted. Each of those uses is then left without a type, and the Problems view reports it until you select another type.

Ask the Assistant

The Assistant and a connected coding agent can create a structure, add fields by hand or from a table's columns, rename it and use it as a type.

If a step fails, see Troubleshoot the first run or contact support.