Skip to content

Relation Record

Relation Record field represents references to data in another table. Relation record represents one-to-one relationships between models.

Description

ItemContent
CategoryAssociation Relationships
SortableYes
FilterableYes
Supported Filter TypesEqual To, Not Equal To, Empty, Not Empty, In List, Not In List

Settings

Setting ItemDescription
Allow emptyControls whether the field is required.
Placeholder when emptyHint text displayed in the input box when no value is entered.
Related tableSelect the data-table module that this field will link to.
Display name field of related recordThe field whose value is shown as the name of the linked record.
Storage field of related recordThe field whose value is stored as the unique identifier of the linked record (defaults to the id field).
Display styleChooses how the field is rendered: Default or Plain text.
Search behaviorChooses how the search box opens: Search in table dialog or Search in dropdown.
Use automation to return search resultsWhen enabled, an automation can supply the list of selectable records.
Automation to call on searchThe automation invoked when the user clicks search (available only if the above option is enabled).
Operation ControlDescription
Open linked record form on clickDetermines whether clicking the field opens the linked record’s form page.
Show linked form as tab in parent formDisplays the linked record’s form page inside the current record using a tab layout.
Edit controlsControls whether users can create a new linked record directly and/or clear an existing selection:
Hide create button, Hide clear button.
Search Page SettingsDescription
Search dialog widthWidth of the search pop-up, 300–1 500 px.
Table styleToggle table appearance: row numbers, border, striped, hide header.
Sub-object fieldSelect a sub-object field from the linked table to render the table as a tree.
Selectable only when condition metExpression that disables rows which do not satisfy the condition.
Fields to displayChoose which fields appear in the search table.
Data filterExpression that filters the records listed in the search dialog.
Searchable fieldsPick fields to be used for searching (field-specific or fuzzy search).
Default sortingDefine the default sort column and order.
Cell formatCreate rules to format cells in the search table; multiple rules allowed.

Storage Format in Database

Stored Field TypeSQL TypeDescription
Stringvarchar(64)Variable-length string, up to 64 characters
Integerint88-byte integer (bigint)

When a record in the related table is deleted, the behavior of the related-record field depends on the settings in the reference table.

  • Cannot be deleted while referenced If the reference table has this option set, then deleting a record in the related table that is referenced by a related-record field will not be allowed.
  • When deleting, simultaneously set the related record in referencing data to null or remove the referenced entry from the association list If the reference table has this option set, then when a record in the related table is deleted, the related-record field in the reference table will be set to null.

show name

When querying record data in automations or scripts, a related-record field always returns both the stored identifier and the configured display-name field.

json
{
  "id": "recordId",
  "field1": "table b record ID",
  "field1_name": "table b record name"
}

TIP

When updating form records via automation, always sync the display-name value of the related-record field so that the linked record shows the correct name.

display style

display style

storage fields

In a related-record field you can pick a specific sub-form entry and store the value of any field within that entry. As shown below, we are storing both the Record ID and the Record Name from the selected sub-form row.

TIP

By default, only the record ID is stored.

search behavior

search behavior

Use automation to return search results

Call an automation to return a list of optional data records

Use cases

  • Based on the current form data, users can select from a list of optional data records
  • Based on the application context (user role, permissions, etc.), control the list of optional data records that users can select from

Usage instructions

  • The return value structure of the automation needs to contain list and count two attributes
  • The list attribute of the automation return value is of type Array<Record>, representing the list of optional data records
  • The count attribute of the automation return value is of type Integer, representing the number of records that satisfy the condition
  • If the automation return value does not contain the count attribute, the length of the list attribute will be used as the default value
  • When the user clicks the search button, the automation will be called with a default parameter of type QueryCondition

Example

Add the following data models

Question table question, fields as follows

IdentifierFieldType
nameQuestion NameSingle-line Text
descsQuestion DescriptionMulti-line Text

Question Detail table questionDetail, fields as follows

IdentifierFieldType
nameNameSingle-line Text
descsDescriptionMulti-line Text
questionRelQuestionRelated Record

In the Question Split Table field, set Use Automation to Return Search Results

  • Field Settings Use Automation to Return Search Results

  • Automation

    • Use Mock Data

      Automation Implementation

    • Return Data from Database Table

      Return Data from Database Table

  • Interface Display

    • Question Table Data

      Question Table Data

    • Question Detail Table Data

      Question Detail Table Data

For Related Record and Related List fields, you can also enable "Automation Pending Values" in the view filter conditions.

  • Filter Condition Pending Values

    Filter Condition Pending Values

  • Interface Display

    Interface Display

In some scenarios, we want the list of selectable related records to change dynamically as the user fills in the form. This can be achieved through the Search Page Settings, which link the form to the selectable list of related records. Below we will demonstrate how adjusting the value of the “Name” field filters the selectable data of the field [Form Internal Data Filter].