@trg-admin/n8n-nodes-zoho-desk 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -166,16 +166,41 @@ class ZohoDesk {
166
166
  name: 'cfTaskId',
167
167
  type: 'string',
168
168
  default: '',
169
- description: 'Custom field Task ID (maps to customFields.cf_task_id)',
169
+ description: 'Custom field Task ID (maps to cf.cf_task_id)',
170
170
  },
171
171
  {
172
- displayName: 'Custom Fields (JSON)',
173
- name: 'customFieldsJson',
174
- type: 'string',
175
- typeOptions: { alwaysOpenEditWindow: true },
176
- default: '',
177
- placeholder: '{"cf_serial_number":"SN-99821","cf_warranty_expiry":"2025-12-31"}',
178
- description: 'Additional custom fields to update, as a JSON object with Zoho API names (for example cf_serial_number)',
172
+ displayName: 'Custom Fields',
173
+ name: 'customFieldsList',
174
+ type: 'fixedCollection',
175
+ typeOptions: {
176
+ multipleValues: true,
177
+ },
178
+ default: {},
179
+ placeholder: 'Add Custom Field',
180
+ description: 'Add one or more custom fields by API name and value',
181
+ options: [
182
+ {
183
+ name: 'field',
184
+ displayName: 'Field',
185
+ values: [
186
+ {
187
+ displayName: 'Field API Name',
188
+ name: 'fieldName',
189
+ type: 'string',
190
+ default: '',
191
+ placeholder: 'cf_serial_number',
192
+ description: 'Zoho custom field API name (for example cf_serial_number)',
193
+ },
194
+ {
195
+ displayName: 'Value',
196
+ name: 'fieldValue',
197
+ type: 'string',
198
+ default: '',
199
+ description: 'Value to set for this custom field',
200
+ },
201
+ ],
202
+ },
203
+ ],
179
204
  },
180
205
  {
181
206
  displayName: 'Due Date',
@@ -402,7 +427,7 @@ class ZohoDesk {
402
427
  async execute() {
403
428
  const items = this.getInputData();
404
429
  const returnData = [];
405
- const parseCustomFields = (raw, itemIndex) => {
430
+ const parseLegacyCustomFieldsJson = (raw, itemIndex) => {
406
431
  if (!raw)
407
432
  return {};
408
433
  if (typeof raw === 'object' && raw !== null) {
@@ -425,6 +450,23 @@ class ZohoDesk {
425
450
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), new Error(`Invalid Custom Fields (JSON): ${error.message}`), { itemIndex });
426
451
  }
427
452
  };
453
+ const parseCustomFieldEntries = (raw) => {
454
+ if (!raw || typeof raw !== 'object') {
455
+ return {};
456
+ }
457
+ const fieldRows = Array.isArray(raw.field)
458
+ ? raw.field
459
+ : [];
460
+ const customFields = {};
461
+ for (const row of fieldRows) {
462
+ const fieldName = String(row.fieldName ?? '').trim();
463
+ if (!fieldName) {
464
+ continue;
465
+ }
466
+ customFields[fieldName] = row.fieldValue ?? '';
467
+ }
468
+ return customFields;
469
+ };
428
470
  for (let i = 0; i < items.length; i++) {
429
471
  const resource = this.getNodeParameter('resource', i);
430
472
  const operation = this.getNodeParameter('operation', i);
@@ -462,8 +504,9 @@ class ZohoDesk {
462
504
  const departmentId = this.getNodeParameter('departmentId', i);
463
505
  const description = this.getNodeParameter('description', i, '');
464
506
  const additionalFields = this.getNodeParameter('additionalFields', i, {});
465
- const { cfTaskId, customFieldsJson, ...otherAdditionalFields } = additionalFields;
466
- const parsedCustomFields = parseCustomFields(customFieldsJson, i);
507
+ const { cfTaskId, customFieldsList, customFieldsJson, ...otherAdditionalFields } = additionalFields;
508
+ const legacyCustomFields = parseLegacyCustomFieldsJson(customFieldsJson, i);
509
+ const listCustomFields = parseCustomFieldEntries(customFieldsList);
467
510
  const body = {
468
511
  subject,
469
512
  email,
@@ -471,13 +514,14 @@ class ZohoDesk {
471
514
  ...otherAdditionalFields,
472
515
  };
473
516
  const customFields = {
474
- ...parsedCustomFields,
517
+ ...legacyCustomFields,
518
+ ...listCustomFields,
475
519
  };
476
520
  if (cfTaskId) {
477
521
  customFields.cf_task_id = cfTaskId;
478
522
  }
479
523
  if (Object.keys(customFields).length > 0) {
480
- body.customFields = customFields;
524
+ body.cf = customFields;
481
525
  }
482
526
  if (description) {
483
527
  body.description = description;
@@ -489,19 +533,21 @@ class ZohoDesk {
489
533
  const ticketId = this.getNodeParameter('ticketId', i);
490
534
  const description = this.getNodeParameter('description', i, '');
491
535
  const additionalFields = this.getNodeParameter('additionalFields', i, {});
492
- const { cfTaskId, customFieldsJson, ...otherAdditionalFields } = additionalFields;
493
- const parsedCustomFields = parseCustomFields(customFieldsJson, i);
536
+ const { cfTaskId, customFieldsList, customFieldsJson, ...otherAdditionalFields } = additionalFields;
537
+ const legacyCustomFields = parseLegacyCustomFieldsJson(customFieldsJson, i);
538
+ const listCustomFields = parseCustomFieldEntries(customFieldsList);
494
539
  const body = {
495
540
  ...otherAdditionalFields,
496
541
  };
497
542
  const customFields = {
498
- ...parsedCustomFields,
543
+ ...legacyCustomFields,
544
+ ...listCustomFields,
499
545
  };
500
546
  if (cfTaskId) {
501
547
  customFields.cf_task_id = cfTaskId;
502
548
  }
503
549
  if (Object.keys(customFields).length > 0) {
504
- body.customFields = customFields;
550
+ body.cf = customFields;
505
551
  }
506
552
  if (description) {
507
553
  body.description = description;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trg-admin/n8n-nodes-zoho-desk",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Community n8n node starter for Zoho Desk using built-in Zoho OAuth2 auth behavior",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",