Manually creating TEnum is typically not required.
Options are generated automatically from the field settings and passed through EnumField.variants.
When working with a form, you can temporarily add options to the EnumField.data.variants property via script.
Such options are displayed in the UI and can be used during the current form session.
After the page is refreshed, they are not saved; however, the selected values remain available in the context of the current form instance.
Where TEnum appears:
as an available option — in EnumField.variants and Context.fields.<field>.data.variants;
as a selected value — in Context.data.<field> (single: TEnum<T>; multiple: TEnum<T>[]).
Type parameters
T: string
Hierarchy
TEnum
Properties
code
code:T
Value’s code.
It is set once and used in the logic and comparison.
Generated automatically from the name of the option or specified manually.
Code transformation rules:
Converted to lowercase.
Sapces are replaced with underscore (_).
Hyphen (-) is preserved.
Most special symbols are replaced with underscore (_).
Digits can be used.
Usage examples:
Business-process — bisness-process;
Client Type — client_type;
Type#1 — type_1;
Orders v2.0 — orders_v2_0.
Usage examples:
// Getting an option by its code const dict = Context.fields.category.variants;
// Codes with symbols invalid for JS identifier are specified only in square brackets const vNum = dict['1n']; // Starts with a digit const vDash = dict['order-type']; // Includes a hyphen // Valid identifier is specified via a dot or in square brackets const v_Ok1 = dict.code1;
const v_Ok2 = dict['code1'];
// Setting selection for the Catgeory type field (One)
Context.data.category = v_Ok1;
// Setting selection for the Category type field (Multiple)
Context.data.category_multi = [v_Ok1, vDash].filter(Boolean);
// Adding available options to the interface using `data.variants` // Temporary options available only in the current form for testing or single actions
Context.fields.category.data.variants.push ({ code: 'temp_one', name: 'Temp ONE' });
Context.fields.category.data.variants.push ({ code: 'temp_two', name: 'Temp TWO' });
// Gettings codes of selected values for the Category type field (Multiple) const selectedCodes: string[] = (Context.data.category_multi ?? []).map(v => v.code);
// Getting codes of available options const availableCodes: string[] = Context.fields.category.data.variants.map(v => v.code);
// Comparing by a code if (v_Ok1.code === 'code1') {
// ...
}
// Displaying the name of the option console.log(v_Ok1.name);
name
name:string
The displayed name of the option visible to the user.
The value can be changed. It does not impact script execution.
Category (enumeration)
Manually creating
TEnumis typically not required. Options are generated automatically from the field settings and passed through EnumField.variants. When working with a form, you can temporarily add options to the EnumField.data.variants property via script. Such options are displayed in the UI and can be used during the current form session. After the page is refreshed, they are not saved; however, the selected values remain available in the context of the current form instance. WhereTEnumappears:Context.fields.<field>.data.variants;Context.data.<field>(single:TEnum<T>; multiple:TEnum<T>[]).Type parameters
T: string
Hierarchy
Properties
code
Value’s code.
It is set once and used in the logic and comparison. Generated automatically from the name of the option or specified manually. Code transformation rules:
// Getting an option by its code const dict = Context.fields.category.variants; // Codes with symbols invalid for JS identifier are specified only in square brackets const vNum = dict['1n']; // Starts with a digit const vDash = dict['order-type']; // Includes a hyphen // Valid identifier is specified via a dot or in square brackets const v_Ok1 = dict.code1; const v_Ok2 = dict['code1']; // Setting selection for the Catgeory type field (One) Context.data.category = v_Ok1; // Setting selection for the Category type field (Multiple) Context.data.category_multi = [v_Ok1, vDash].filter(Boolean); // Adding available options to the interface using `data.variants` // Temporary options available only in the current form for testing or single actions Context.fields.category.data.variants.push ({ code: 'temp_one', name: 'Temp ONE' }); Context.fields.category.data.variants.push ({ code: 'temp_two', name: 'Temp TWO' }); // Gettings codes of selected values for the Category type field (Multiple) const selectedCodes: string[] = (Context.data.category_multi ?? []).map(v => v.code); // Getting codes of available options const availableCodes: string[] = Context.fields.category.data.variants.map(v => v.code); // Comparing by a code if (v_Ok1.code === 'code1') { // ... } // Displaying the name of the option console.log(v_Ok1.name);name
The displayed name of the option visible to the user.
The value can be changed. It does not impact script execution.