From 45c5847f5aae64f035ed2b0f4d2ef632f3a0bc3f Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Mon, 8 Sep 2025 20:46:11 +0200 Subject: [PATCH] Fix duplicate field name issue in custom triggers - Remove redundant field name prefixing in Workflow.ts - Custom trigger fields from trigger-helpers already have unique names - Simplify by passing through inputs without modification - Fixes DuplicateFieldName error --- src/collections/Workflow.ts | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/src/collections/Workflow.ts b/src/collections/Workflow.ts index e5565d0..002b592 100644 --- a/src/collections/Workflow.ts +++ b/src/collections/Workflow.ts @@ -296,34 +296,9 @@ export const createWorkflowCollection: (options: WorkflowsPlug required: false }, // Virtual fields for custom triggers - ...(triggers || []).flatMap(t => (t.inputs || []).filter(f => 'name' in f && f.name).map(f => ({ - ...f, - // Prefix field name with trigger slug to avoid conflicts - name: `__${t.slug}_${(f as any).name}`, - admin: { - ...(f.admin || {}), - condition: (...args) => args[1]?.type === t.slug && ( - f.admin?.condition ? - f.admin.condition.call(this, ...args) : - true - ), - }, - hooks: { - afterRead: [ - ({ siblingData }) => { - return siblingData?.parameters?.[(f as any).name] || undefined - } - ], - beforeChange: [ - ({ siblingData, value }) => { - if (!siblingData.parameters) {siblingData.parameters = {}} - siblingData.parameters[(f as any).name] = value - return undefined // Virtual field, don't store directly - } - ] - }, - virtual: true, - } as Field))) + // Note: Custom trigger fields from trigger-helpers already have unique names + // We just need to pass them through without modification + ...(triggers || []).flatMap(t => (t.inputs || [])) ] }, {