@trg-admin/n8n-nodes-zoho-desk 0.1.12 → 0.1.13
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.
|
@@ -168,6 +168,15 @@ class ZohoDesk {
|
|
|
168
168
|
default: '',
|
|
169
169
|
description: 'Custom field Task ID (maps to customFields.cf_task_id)',
|
|
170
170
|
},
|
|
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)',
|
|
179
|
+
},
|
|
171
180
|
{
|
|
172
181
|
displayName: 'Due Date',
|
|
173
182
|
name: 'dueDate',
|
|
@@ -393,6 +402,29 @@ class ZohoDesk {
|
|
|
393
402
|
async execute() {
|
|
394
403
|
const items = this.getInputData();
|
|
395
404
|
const returnData = [];
|
|
405
|
+
const parseCustomFields = (raw, itemIndex) => {
|
|
406
|
+
if (!raw)
|
|
407
|
+
return {};
|
|
408
|
+
if (typeof raw === 'object' && raw !== null) {
|
|
409
|
+
return raw;
|
|
410
|
+
}
|
|
411
|
+
if (typeof raw !== 'string' || raw.trim() === '') {
|
|
412
|
+
return {};
|
|
413
|
+
}
|
|
414
|
+
try {
|
|
415
|
+
const parsed = JSON.parse(raw);
|
|
416
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
417
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), new Error('Custom Fields (JSON) must be a JSON object, for example {"cf_serial_number":"SN-99821"}'), { itemIndex });
|
|
418
|
+
}
|
|
419
|
+
return parsed;
|
|
420
|
+
}
|
|
421
|
+
catch (error) {
|
|
422
|
+
if (error instanceof n8n_workflow_1.NodeOperationError) {
|
|
423
|
+
throw error;
|
|
424
|
+
}
|
|
425
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), new Error(`Invalid Custom Fields (JSON): ${error.message}`), { itemIndex });
|
|
426
|
+
}
|
|
427
|
+
};
|
|
396
428
|
for (let i = 0; i < items.length; i++) {
|
|
397
429
|
const resource = this.getNodeParameter('resource', i);
|
|
398
430
|
const operation = this.getNodeParameter('operation', i);
|
|
@@ -430,17 +462,22 @@ class ZohoDesk {
|
|
|
430
462
|
const departmentId = this.getNodeParameter('departmentId', i);
|
|
431
463
|
const description = this.getNodeParameter('description', i, '');
|
|
432
464
|
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
433
|
-
const { cfTaskId, ...otherAdditionalFields } = additionalFields;
|
|
465
|
+
const { cfTaskId, customFieldsJson, ...otherAdditionalFields } = additionalFields;
|
|
466
|
+
const parsedCustomFields = parseCustomFields(customFieldsJson, i);
|
|
434
467
|
const body = {
|
|
435
468
|
subject,
|
|
436
469
|
email,
|
|
437
470
|
departmentId,
|
|
438
471
|
...otherAdditionalFields,
|
|
439
472
|
};
|
|
473
|
+
const customFields = {
|
|
474
|
+
...parsedCustomFields,
|
|
475
|
+
};
|
|
440
476
|
if (cfTaskId) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
477
|
+
customFields.cf_task_id = cfTaskId;
|
|
478
|
+
}
|
|
479
|
+
if (Object.keys(customFields).length > 0) {
|
|
480
|
+
body.customFields = customFields;
|
|
444
481
|
}
|
|
445
482
|
if (description) {
|
|
446
483
|
body.description = description;
|
|
@@ -452,14 +489,19 @@ class ZohoDesk {
|
|
|
452
489
|
const ticketId = this.getNodeParameter('ticketId', i);
|
|
453
490
|
const description = this.getNodeParameter('description', i, '');
|
|
454
491
|
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
455
|
-
const { cfTaskId, ...otherAdditionalFields } = additionalFields;
|
|
492
|
+
const { cfTaskId, customFieldsJson, ...otherAdditionalFields } = additionalFields;
|
|
493
|
+
const parsedCustomFields = parseCustomFields(customFieldsJson, i);
|
|
456
494
|
const body = {
|
|
457
495
|
...otherAdditionalFields,
|
|
458
496
|
};
|
|
497
|
+
const customFields = {
|
|
498
|
+
...parsedCustomFields,
|
|
499
|
+
};
|
|
459
500
|
if (cfTaskId) {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
501
|
+
customFields.cf_task_id = cfTaskId;
|
|
502
|
+
}
|
|
503
|
+
if (Object.keys(customFields).length > 0) {
|
|
504
|
+
body.customFields = customFields;
|
|
463
505
|
}
|
|
464
506
|
if (description) {
|
|
465
507
|
body.description = description;
|