Sandbox: ctx.tasks.setFieldValue искал несуществующий fieldCode + логирование триггерных автоматизаций

- automation-worker-code: getFormFields возвращает поле code (не fieldCode) — поиск поля всегда завершался ошибкой 'Field ... not found', ошибка терялась
- automation.routes: результаты runAutomationsByTrigger (логи, ошибки) теперь пишутся в консоль сервиса с префиксом [automation]
This commit is contained in:
2026-09-06 13:37:44 +03:00
parent 0bde7764b1
commit 2960879fa9
2 changed files with 7 additions and 1 deletions

View File

@@ -172,6 +172,12 @@ export async function runAutomationsByTrigger(
organizationId, organizationId,
triggerData, triggerData,
); );
// Логи выполнения триггерных автоматизаций идут в консоль сервиса (иначе результаты теряются)
if (error) {
console.error(`[automation] ${automation.id} "${automation.name}" — ошибка:`, error, '| логи:', logs);
} else {
console.log(`[automation] ${automation.id} "${automation.name}" — выполнена | логи:`, logs);
}
results.push({ automationId: automation.id, name: automation.name, logs, error, result }); results.push({ automationId: automation.id, name: automation.name, logs, error, result });
} }

View File

@@ -95,7 +95,7 @@ const ctx = {
const task = await callStorage('getTask', [taskId, organizationId]); const task = await callStorage('getTask', [taskId, organizationId]);
if (!task) throw new Error('Task ' + taskId + ' not found'); if (!task) throw new Error('Task ' + taskId + ' not found');
const formFields = await callStorage('getFormFields', [task.formId, organizationId]); const formFields = await callStorage('getFormFields', [task.formId, organizationId]);
const field = formFields.find(function(f) { return f.fieldCode === fieldCode; }); const field = formFields.find(function(f) { return (f.fieldCode || f.code) === fieldCode; });
if (!field) throw new Error('Field ' + fieldCode + ' not found'); if (!field) throw new Error('Field ' + fieldCode + ' not found');
const existing = fields.find(function(v) { return v.fieldId === field.id; }); const existing = fields.find(function(v) { return v.fieldId === field.id; });
if (existing) { if (existing) {