From b3fc00e045dc16f758b684b71591ec2d1f889d73 Mon Sep 17 00:00:00 2001 From: Elias Meire Date: Wed, 4 Oct 2023 12:39:31 +0200 Subject: [PATCH] fix(Typeform Trigger Node): Change output format for TypeForm trigger to object instead of array (#7315) Github issue / Community forum post (link here to close automatically): --------- Co-authored-by: Michael Kret --- .../nodes/Typeform/TypeformTrigger.node.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts b/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts index bfda4406b8..5b85262a6e 100644 --- a/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts +++ b/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts @@ -25,7 +25,7 @@ export class TypeformTrigger implements INodeType { name: 'typeformTrigger', icon: 'file:typeform.svg', group: ['trigger'], - version: 1, + version: [1, 1.1], subtitle: '=Form ID: {{$parameter["formId"]}}', description: 'Starts the workflow on a Typeform form submission', defaults: { @@ -220,6 +220,7 @@ export class TypeformTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { + const version = this.getNode().typeVersion; const bodyData = this.getBodyData(); const simplifyAnswers = this.getNodeParameter('simplifyAnswers') as boolean; @@ -278,7 +279,23 @@ export class TypeformTrigger implements INodeType { } if (onlyAnswers) { - // Return only the answer + // Return only the answers + if (version >= 1.1) { + return { + workflowData: [ + this.helpers.returnJsonArray([ + answers.reduce( + (acc, answer) => { + acc[answer.field.id] = answer; + return acc; + }, + {} as Record, + ), + ]), + ], + }; + } + return { workflowData: [this.helpers.returnJsonArray([answers as unknown as IDataObject])], };