GlobalConstants — global constant
Updated
What it is#
A configuration value outside code: a threshold, a mode, the number of decimal places — anything that would otherwise become a magic number in a script. It is edited in the designer/data, without rebuilding. Each constant belongs to a group (groupMetaId) so the settings UI can group it.
JSON envelope#
<Name>.json, "kind": "GlobalConstant" — one file per constant, with type and value in one record:
{
"kind": "GlobalConstant",
"object": {
"caption": { "en": "Weight scale (decimal places)", "ru": "Знаков после запятой в весе" },
"groupMetaId": "<GUID Group>",
"constantType": "Integer",
"numberValue": 3.00,
"value": 3,
"displayValue": "3",
"metaId": "<GUID Constant>", "name": "WeightScale", "modelId": "<GUID Model>"
}
}
constantType determines which value fields to read (numberValue/value/displayValue). Numeric types duplicate the value in numberValue (machine-readable) and value/displayValue (what the form shows).
The group referenced by groupMetaId is declared in a separate _groups.json file in the same folder ("kind": "ConstantGroups") — a list of { caption, metaId, name, modelId } records. The constant itself only references the needed group's metaId; it does not create the group implicitly.
C# base#
No separate class. Reading uses IConstantResolver/IGlobalConstantManager: typed as GlobalConstants.<Group>.<Name>, or Get<T>() by name; writing uses SetAsync.
Events / Chain of Command#
None.
Example#
WeightScale (Integer, value 3) in Common — the number of decimal places for item weight in all input forms.