From 2f81652400b6a793fa610728519fd992c03c3d0d Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 23 Aug 2023 16:04:57 +0100 Subject: [PATCH] fix(Agile CRM Node): Fix issue with company address not working (#6997) --- .../nodes/AgileCrm/AgileCrm.node.ts | 51 ++++++++--- .../nodes/AgileCrm/CompanyDescription.ts | 88 +++++++++++++++++-- 2 files changed, 117 insertions(+), 22 deletions(-) diff --git a/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts b/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts index 51d32d3d662ae..27fc4689f17e2 100644 --- a/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts +++ b/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts @@ -298,12 +298,16 @@ export class AgileCrm implements INodeType { } as IDataObject); } - if (additionalFields.address) { - properties.push({ - type: 'SYSTEM', - name: 'address', - value: additionalFields.address as string, - } as IDataObject); + if (additionalFields.addressOptions) { + //@ts-ignore + additionalFields.addressOptions.addressProperties.map((property) => { + properties.push({ + type: 'SYSTEM', + subtype: property.subtype as string, + name: 'address', + value: property.address as string, + } as IDataObject); + }); } if (additionalFields.phone) { @@ -313,6 +317,14 @@ export class AgileCrm implements INodeType { value: additionalFields.phone as string, } as IDataObject); } + + if (additionalFields.name) { + properties.push({ + type: 'SYSTEM', + name: 'name', + value: additionalFields.name as string, + } as IDataObject); + } } if (additionalFields.websiteOptions) { @@ -321,7 +333,7 @@ export class AgileCrm implements INodeType { properties.push({ type: 'SYSTEM', subtype: property.subtype as string, - name: 'webiste', + name: 'website', value: property.url as string, } as IDataObject); }); @@ -450,12 +462,16 @@ export class AgileCrm implements INodeType { } as IDataObject); } - if (additionalFields.address) { - properties.push({ - type: 'SYSTEM', - name: 'address', - value: additionalFields.address as string, - } as IDataObject); + if (additionalFields.addressOptions) { + //@ts-ignore + additionalFields.addressOptions.addressProperties.map((property) => { + properties.push({ + type: 'SYSTEM', + subtype: property.subtype as string, + name: 'address', + value: property.address as string, + } as IDataObject); + }); } if (additionalFields.phone) { @@ -473,11 +489,18 @@ export class AgileCrm implements INodeType { properties.push({ type: 'SYSTEM', subtype: property.subtype as string, - name: 'webiste', + name: 'website', value: property.url as string, } as IDataObject); }); } + if (additionalFields.name) { + properties.push({ + type: 'SYSTEM', + name: 'name', + value: additionalFields.name as string, + } as IDataObject); + } if (additionalFields.customProperties) { //@ts-ignore additionalFields.customProperties.customProperty.map((property) => { diff --git a/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts b/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts index dc30e3e00d8c5..97ac7aa72ae76 100644 --- a/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts +++ b/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts @@ -379,11 +379,47 @@ export const companyFields: INodeProperties[] = [ options: [ { displayName: 'Address', - name: 'email', - type: 'string', - placeholder: 'name@email.com', - default: '', + name: 'addressOptions', + type: 'fixedCollection', + default: {}, description: 'Company address', + typeOptions: { + multipleValues: true, + }, + options: [ + { + displayName: 'Address Properties', + name: 'addressProperties', + values: [ + { + displayName: 'Type', + name: 'subtype', + type: 'options', + required: true, + default: '', + description: 'Type of address', + options: [ + { + name: 'Postal', + value: 'postal', + }, + { + name: 'Office', + value: 'office', + }, + ], + }, + { + displayName: 'Address', + name: 'address', + type: 'string', + required: true, + default: '', + description: 'Full address', + }, + ], + }, + ], }, { displayName: 'Email', @@ -655,11 +691,47 @@ export const companyFields: INodeProperties[] = [ options: [ { displayName: 'Address', - name: 'email', - type: 'string', - placeholder: 'name@email.com', - default: '', + name: 'addressOptions', + type: 'fixedCollection', + default: {}, description: 'Company address', + typeOptions: { + multipleValues: true, + }, + options: [ + { + displayName: 'Address Properties', + name: 'addressProperties', + values: [ + { + displayName: 'Type', + name: 'subtype', + type: 'options', + required: true, + default: '', + description: 'Type of address', + options: [ + { + name: 'Postal', + value: 'postal', + }, + { + name: 'Office', + value: 'office', + }, + ], + }, + { + displayName: 'Address', + name: 'address', + type: 'string', + required: true, + default: '', + description: 'Full address', + }, + ], + }, + ], }, { displayName: 'Email',