Default value

Default value is set when you need to output the value in the attribute field automatically when you open the object creation form. The default value is set by assigning the default value to the "defaultValue" property . The main use is for selection lists of acceptable values.

Example

{
      "orderNumber": 20,
      "name": "defaultValue",
      "caption": "Значение поля",
      "type": 0,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": true,
      "readonly": false,
      "indexed": false,
      "unique": false,
      "autoassigned": false,
      "hint": null,
      "defaultValue": "default",
      "refClass": "",
      "itemsClass": "",
      "backRef": "",
      "backColl": "",
      "binding": "",
      "semantic": null,
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": {
        "type": "SIMPLE",
        "list": [
          {
            "key": "default",
            "value": "Значение, которое отображается по умолчанию при создании объекта"
          },
          {
            "key": "other",
            "value": "Другое значение"
          }
        ],
        "matrix": [],
        "parameters": [],
        "hq": ""
      },
      "indexSearch": false,
      "eagerLoading": false,
      "formula": null
 }

To implement ** automatic calculation of the default value**you can use the maxfunction:

"defaultValue": {max: ["className@namespace", "attr", {"filterAttr": "filterValue"}]}

Use the get operation to implement default value for the “Reference” attribute type in the following ways:

get(className) // возвращаем id случайно выбранного объекта класса
get(className, id) // проверяем наличие объекта в БД, если объект есть, возвращаем его id
get(className, attr1, val1, attr2, val2, ...) // возвращаем id первого объекта удовлетворяющего критериям поиска: attr1=val1 и attr2=val2 и т.д.