Платформа 3V/Отчет/2. Настроить столбцы/2.5. Дополнительные настройки/Установка значения по умолчанию

Материал из 3v-wiki
< Платформа 3V‎ | Отчет‎ | 2. Настроить столбцы‎ | 2.5. Дополнительные настройки
Версия от 12:10, 4 мая 2021; A.saydakova (обсуждение | вклад) (Новая страница: «При необходимости указать значение по умолчанию для какого-либо столбца отчета существ...»)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к навигации Перейти к поиску

При необходимости указать значение по умолчанию для какого-либо столбца отчета существует две различные ситуации, от которых зависит способ настройки данного значения. Установка значения по умолчанию:

  1. В атрибут справочника
  2. В факт показателя

Установка значения по умолчанию в атрибут справочника

Для установки значения по умолчанию в столбец отчета, который является атрибутом справочника, необходимо в самом справочнике в требуемом атрибуте указать свойство defaultValue или defaultValueExpression при постоянном значении по умолчанию или вычисляемом определенным выражением соответственно

"sortings": [ ]
 1 "view": 
 2     {
 3      "id": 21,
 4      "name": "...",
 5      "code": "...",
 6      ...
 7      "defaultValue": "...",
 8      "defaultValueExpression": "..."
 9      ...
10     }

Кейс: Существует справочник "Заявки на работу" и необходимо в атрибут "Номер заявки" указать значение по умолчанию "Новая заявка", а атрибут "Дата создания" вычислить и заполнить текущей датой и атрибут "Актуальность" по умолчанию заполнить True

Номер заявки (id=2) Дата создания (id=21) Актуальность (id=22)
102-1-1 02.02.2021 True
102-1-2 09.04.2021 False
... ... ...
Установка значения по умолчанию. атрибут справочник.gif
Настройки атрибутов в справочнике. "attributes": [...]
 1       {
 2         "id": 2,
 3         "name": "Номер заявки",
 4         "code": "NAME",
 5         "description": "",
 6         "dataType": "String",
 7         "type": "Name",
 8         "isNullable": false,
 9         "hasMultipleValues": false,
10         "isVisible": true,
11         "isReadOnly": false,
12         "formula": null,
13         "tableName": "",
14         "identIndex": {
15           "code": null,
16           "isUnique": false,
17           "dbIndexName": null,
18           "fields": [],
19           "isNew": true
20         },
21         "referenceIndex": {
22           "code": null,
23           "isUnique": false,
24           "dbIndexName": null,
25           "fields": [],
26           "isNew": true
27         },
28         "attributeLink": null,
29         "defaultValue": "Новая заявка",
30         "defaultValueExpression": null,
31         "userAttributePermissions": null,
32         "component": null
33       },
34       {
35         "id": 21,
36         "name": "Дата создания",
37         "code": "DATE_CREATE",
38         "description": "",
39         "dataType": "DateTime",
40         "type": "Custom",
41         "isNullable": true,
42         "hasMultipleValues": false,
43         "isVisible": true,
44         "isReadOnly": false,
45         "formula": null,
46         "tableName": "",
47         "identIndex": {
48           "code": null,
49           "isUnique": false,
50           "dbIndexName": null,
51           "fields": [],
52           "isNew": true
53         },
54         "referenceIndex": {
55           "code": null,
56           "isUnique": false,
57           "dbIndexName": null,
58           "fields": [],
59           "isNew": true
60         },
61         "attributeLink": null,
62         "defaultValue": null,
63         "defaultValueExpression": "Today()",
64         "userAttributePermissions": null,
65         "component": null
66       },
67       {
68         "id": 22,
69         "name": "Актуальность",
70         "code": "ACTUAL",
71         "description": "",
72         "dataType": "Boolean",
73         "type": "Custom",
74         "isNullable": true,
75         "hasMultipleValues": false,
76         "isVisible": true,
77         "isReadOnly": false,
78         "formula": null,
79         "tableName": "",
80         "identIndex": {
81           "code": null,
82           "isUnique": false,
83           "dbIndexName": null,
84           "fields": [],
85           "isNew": true
86         },
87         "referenceIndex": {
88           "code": null,
89           "isUnique": false,
90           "dbIndexName": null,
91           "fields": [],
92           "isNew": true
93         },
94         "attributeLink": null,
95         "defaultValue": "true",
96         "defaultValueExpression": null,
97         "userAttributePermissions": null,
98         "component": null
99       }

При этом в самом отчете никакой дополнительной настройки не требуется:

JSON отчета
  1       {
  2   "workflowId": null,
  3   "leftHeader": {
  4     "useLazyDataLoadingStrategy": false,
  5     "dictionaries": [
  6       {
  7         "showDataIfAbsentFilter": null,
  8         "coordAttribute": null,
  9         "cartesianOptions": "Default",
 10         "canSelectAttribute": null,
 11         "groupingOptions": null,
 12         "groupingMethod": "Default",
 13         "sortingOptions": null,
 14         "rootElement": null,
 15         "virtualElements": null,
 16         "displayValueOptions": null,
 17         "displayAttribute": null,
 18         "dictionaryId": 185,
 19         "filter": {
 20           "value": null,
 21           "skipIfValueNull": false,
 22           "attributeId": null,
 23           "attribute": {
 24             "id": 1,
 25             "discriminator": "OwnAttributeDefinitionDto"
 26           },
 27           "conditionType": "AllElements",
 28           "inversion": false,
 29           "discriminator": "ValueConditionalDictionaryFilterDto"
 30         },
 31         "selection": null,
 32         "hierarchyId": null,
 33         "limit": null
 34       }
 35     ],
 36     "dictionaryAttributesLinks": [],
 37     "specialFilters": {
 38       "filtersByDataOptions": {
 39         "filtersByData": [],
 40         "needRestoreFullHierachy": false,
 41         "joinOption": "Or",
 42         "restoreElements": null
 43       },
 44       "dictionaryAttributesLinks": [],
 45       "needRestoreFullHierachy": false,
 46       "restoreElements": null
 47     },
 48     "isEditable": false
 49   },
 50   "topHeader": {
 51     "topHeaderItems": [
 52       {
 53         "dictionaryAttributes": [
 54           {
 55             "dictionaryId": 185,
 56             "attribute": {
 57               "id": 2,
 58               "discriminator": "OwnAttributeDefinitionDto"
 59             },
 60             "filter": null,
 61             "sortingOptions": null,
 62             "attributeId": null,
 63             "displayAttributeType": "AttributeName",
 64             "displayAttributeName": null,
 65             "addFirstElementValue": false,
 66             "overwriteNotFirstElementValues": true,
 67             "delimiter": ", ",
 68             "hideAttributeNameInHeader": false,
 69             "headerNameDelimiter": " / ",
 70             "duplicateValuesForNextDictionaries": true,
 71             "duplicateValuesForNextRows": true,
 72             "displayValueOptions": null,
 73             "linkedAttributeSettings": null,
 74             "skippedFilterAttributesByLink": [],
 75             "filterOptionsByLinks": null
 76           }
 77         ],
 78         "settings": null,
 79         "hyperlinkOptions": null,
 80         "hasImage": false,
 81         "columnOptions": null,
 82         "discriminator": "AttributeHeaderItemDto"
 83       },
 84       {
 85         "dictionaryAttributes": [
 86           {
 87             "dictionaryId": 185,
 88             "attribute": {
 89               "id": 21,
 90               "discriminator": "OwnAttributeDefinitionDto"
 91             },
 92             "filter": null,
 93             "sortingOptions": null,
 94             "attributeId": null,
 95             "displayAttributeType": "AttributeName",
 96             "displayAttributeName": null,
 97             "addFirstElementValue": false,
 98             "overwriteNotFirstElementValues": true,
 99             "delimiter": ", ",
100             "hideAttributeNameInHeader": false,
101             "headerNameDelimiter": " / ",
102             "duplicateValuesForNextDictionaries": true,
103             "duplicateValuesForNextRows": true,
104             "displayValueOptions": null,
105             "linkedAttributeSettings": null,
106             "skippedFilterAttributesByLink": [],
107             "filterOptionsByLinks": null
108           }
109         ],
110         "settings": null,
111         "hyperlinkOptions": null,
112         "hasImage": false,
113         "columnOptions": null,
114         "discriminator": "AttributeHeaderItemDto"
115       },
116       {
117         "dictionaryAttributes": [
118           {
119             "dictionaryId": 185,
120             "attribute": {
121               "id": 22,
122               "discriminator": "OwnAttributeDefinitionDto"
123             },
124             "filter": null,
125             "sortingOptions": null,
126             "attributeId": null,
127             "displayAttributeType": "AttributeName",
128             "displayAttributeName": null,
129             "addFirstElementValue": false,
130             "overwriteNotFirstElementValues": true,
131             "delimiter": ", ",
132             "hideAttributeNameInHeader": false,
133             "headerNameDelimiter": " / ",
134             "duplicateValuesForNextDictionaries": true,
135             "duplicateValuesForNextRows": true,
136             "displayValueOptions": null,
137             "linkedAttributeSettings": null,
138             "skippedFilterAttributesByLink": [],
139             "filterOptionsByLinks": null
140           }
141         ],
142         "settings": null,
143         "hyperlinkOptions": null,
144         "hasImage": false,
145         "columnOptions": {
146           "width": 150,
147           "format": null,
148           "dataControlOptions": {
149             "format": null,
150             "mask": null,
151             "min": null,
152             "max": null,
153             "component": null,
154             "searchSettings": null
155           },
156           "isReadOnly": null,
157           "displayDuplicatedValues": null,
158           "duplicateValueOptions": "Undefined",
159           "allowChangeColumnValue": null,
160           "singleValueColumn": null,
161           "hyperlinkOptions": null,
162           "imageType": "None",
163           "absentDictionariesOptions": null
164         },
165         "discriminator": "AttributeHeaderItemDto"
166       }
167     ],
168     "needFilterAttributesByLinks": false,
169     "enableFilterByLinks": false,
170     "numerationSettings": null,
171     "filterOptions": null
172   },
173   "parameters": [],
174   "styles": [],
175   "styleOptions": [],
176   "stylesTemplate": [],
177   "filtersByDataOptions": null,
178   "view": null,
179   "externalExecutions": null,
180   "settings": null,
181   "code": "P_DEFAULT_DICT",
182   "id": 186,
183   "name": "Значение по умолчанию в атрибуте справочника"
184 }