feat: ctx.users.recalcFieldAverage + документация автопересчёта среднего history-number
This commit is contained in:
@@ -2423,7 +2423,8 @@ Users:
|
||||
- ctx.users.get(userId) — get one user
|
||||
- ctx.users.update(userId, updates) — update user fields (firstName, lastName, position, statusId, etc.)
|
||||
- ctx.users.updateStatus(userId, statusId) — change user status
|
||||
- ctx.users.setFieldValue(userId, fieldCodeOrId, value) — set a user profile custom field value by field id or code (with audit as 'Автоматизация'). For fields of type 'history-number' the numeric value is also appended to user_field_history (linked to the trigger task); a non-numeric value throws an error.
|
||||
- ctx.users.setFieldValue(userId, fieldCodeOrId, value) — set a user profile custom field value by field id or code (with audit as 'Автоматизация'). For fields of type 'history-number' the numeric value is appended to user_field_history (linked to the trigger task) and the field value is set to the current-month average (auto-recalculated); a non-numeric value throws an error.
|
||||
- ctx.users.recalcFieldAverage(userId, fieldCodeOrId) — recalculate the current-month average of a history-number field from user_field_history (use from schedule automations for monthly reset; clears the field if no entries this month).
|
||||
|
||||
Trigger types: 'manual', 'task.before_create', 'task.created', 'task.status_changed', 'qr.scan', 'schedule'
|
||||
TriggerConfig for task.before_create / task.created / task.status_changed: { formId: number, statusId?: number } — statusId applies only to task.status_changed and limits firing to transitions INTO that status
|
||||
|
||||
@@ -68,6 +68,9 @@ const ctx = {
|
||||
: null;
|
||||
return callStorage('setUserProfileFieldValueFromAutomation', [userId, fieldCodeOrId, value, organizationId, taskId]);
|
||||
},
|
||||
recalcFieldAverage: function(userId, fieldCodeOrId) {
|
||||
return callStorage('recalcUserFieldAverageFromAutomation', [userId, fieldCodeOrId, organizationId]);
|
||||
},
|
||||
},
|
||||
tasks: {
|
||||
list: function(formId) { return callStorage('getTasksByForm', [formId, organizationId]); },
|
||||
|
||||
Reference in New Issue
Block a user