Usually, you don't need to create TEnum manually.
Options are generated automatically from the field settings and passed through [[EnumField. variants]].
When working with a form, you can add temporary options to the EnumField.data.variants property using a script.
Such options are visible in the interface and can be used in the current form session.
After page update, they are not saved, but selected values are available in the context of the current form instance.
Where TEnum is used:
As available option — in EnumField.variants and Context.fields.<field>.data .variants.
As 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)
Usually, you don't need to create
TEnummanually. Options are generated automatically from the field settings and passed through [[EnumField. variants]]. When working with a form, you can add temporary options to the EnumField.data.variants property using a script. Such options are visible in the interface and can be used in the current form session. After page update, they are not saved, but selected values are available in the context of the current form instance. WhereTEnumis used: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.