From ea5db680cd88fedde6ce08460c67c12176c56825 Mon Sep 17 00:00:00 2001 From: Job Nijenhuis Date: Tue, 30 Sep 2025 09:04:46 +0200 Subject: [PATCH 1/4] Add Set Custom Ticket Fields action for Zendesk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added new action to set one or more custom field values on a Zendesk ticket using the Zendesk API. Features: - Supports setting multiple custom fields in a single action - Accepts array of custom field objects with id and value properties - Includes validation for required properties - Supports custom subdomain for enterprise accounts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../set-custom-ticket-fields.mjs | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs diff --git a/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs b/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs new file mode 100644 index 0000000000000..c01a49cbb44e1 --- /dev/null +++ b/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs @@ -0,0 +1,82 @@ +import app from "../../zendesk.app.mjs"; + +export default { + key: "zendesk-set-custom-ticket-fields", + name: "Set Custom Ticket Fields", + description: "Sets one or more custom field values on a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).", + type: "action", + version: "0.0.1", + props: { + app, + ticketId: { + propDefinition: [ + app, + "ticketId", + ], + }, + customFields: { + type: "string[]", + label: "Custom Fields", + description: "Array of custom field objects. Each item should be formatted as `{\"id\": \"field_id\", \"value\": \"field_value\"}`. Example: `{\"id\": \"23129751115165\", \"value\": \"ABCDE\"}`", + }, + customSubdomain: { + propDefinition: [ + app, + "customSubdomain", + ], + }, + }, + methods: { + updateTicket({ + ticketId, ...args + } = {}) { + return this.app.update({ + path: `/tickets/${ticketId}`, + ...args, + }); + }, + }, + async run({ $: step }) { + const { + ticketId, + customFields, + customSubdomain, + } = this; + + // Parse custom fields from string array to objects + const parsedCustomFields = customFields.map((field) => { + try { + return typeof field === "string" + ? JSON.parse(field) + : field; + } catch (error) { + throw new Error(`Failed to parse custom field: ${field}. Each field must be valid JSON with "id" and "value" properties.`); + } + }); + + // Validate custom fields structure + parsedCustomFields.forEach((field, index) => { + if (!field.id) { + throw new Error(`Custom field at index ${index} is missing required "id" property`); + } + if (field.value === undefined) { + throw new Error(`Custom field at index ${index} is missing required "value" property`); + } + }); + + const response = await this.updateTicket({ + step, + ticketId, + customSubdomain, + data: { + ticket: { + custom_fields: parsedCustomFields, + }, + }, + }); + + step.export("$summary", `Successfully updated ${parsedCustomFields.length} custom field(s) on ticket ${response.ticket.id}`); + + return response; + }, +}; From c2c2b7a34e17878b0dcf9c65016b439b26a3c32c Mon Sep 17 00:00:00 2001 From: Job Nijenhuis Date: Tue, 30 Sep 2025 09:09:25 +0200 Subject: [PATCH 2/4] Bump version to 0.9.1 --- components/zendesk/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/zendesk/package.json b/components/zendesk/package.json index 58a97676945b3..22e56c990295b 100644 --- a/components/zendesk/package.json +++ b/components/zendesk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/zendesk", - "version": "0.9.0", + "version": "0.9.1", "description": "Pipedream Zendesk Components", "main": "zendesk.app.mjs", "keywords": [ From 37750bc4da51ecc74504aff6588e67d37d784629 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 1 Oct 2025 11:15:25 -0400 Subject: [PATCH 3/4] updates --- .../set-custom-ticket-fields.mjs | 11 ++------ components/zendesk/common/utils.mjs | 25 +++++++++++++++++++ components/zendesk/package.json | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 components/zendesk/common/utils.mjs diff --git a/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs b/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs index c01a49cbb44e1..bea28edf79a84 100644 --- a/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs +++ b/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs @@ -1,4 +1,5 @@ import app from "../../zendesk.app.mjs"; +import { parseObject } from "../../common/utils.mjs"; export default { key: "zendesk-set-custom-ticket-fields", @@ -44,15 +45,7 @@ export default { } = this; // Parse custom fields from string array to objects - const parsedCustomFields = customFields.map((field) => { - try { - return typeof field === "string" - ? JSON.parse(field) - : field; - } catch (error) { - throw new Error(`Failed to parse custom field: ${field}. Each field must be valid JSON with "id" and "value" properties.`); - } - }); + const parsedCustomFields = parseObject(customFields); // Validate custom fields structure parsedCustomFields.forEach((field, index) => { diff --git a/components/zendesk/common/utils.mjs b/components/zendesk/common/utils.mjs new file mode 100644 index 0000000000000..c2b75bdc360c0 --- /dev/null +++ b/components/zendesk/common/utils.mjs @@ -0,0 +1,25 @@ +export const parseObject = (obj) => { + if (!obj) { + return {}; + } + if (typeof obj === "string") { + try { + return JSON.parse(obj); + } catch { + return obj; + } + } + if (Array.isArray(obj)) { + return obj.map(parseObject); + } + if (typeof obj === "object") { + return Object.fromEntries(Object.entries(obj).map(([ + key, + value, + ]) => [ + key, + parseObject(value), + ])); + } + return obj; +}; diff --git a/components/zendesk/package.json b/components/zendesk/package.json index 22e56c990295b..2c7d0f93f99f7 100644 --- a/components/zendesk/package.json +++ b/components/zendesk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/zendesk", - "version": "0.9.1", + "version": "0.10.0", "description": "Pipedream Zendesk Components", "main": "zendesk.app.mjs", "keywords": [ From 796fb65142d1fdfbbbd0f13b1d62cf8b1ed86421 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 1 Oct 2025 11:25:03 -0400 Subject: [PATCH 4/4] updates --- .../set-custom-ticket-fields.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs b/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs index bea28edf79a84..ff04d705cfa88 100644 --- a/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs +++ b/components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs @@ -1,5 +1,6 @@ import app from "../../zendesk.app.mjs"; import { parseObject } from "../../common/utils.mjs"; +import { ConfigurationError } from "@pipedream/platform"; export default { key: "zendesk-set-custom-ticket-fields", @@ -47,13 +48,17 @@ export default { // Parse custom fields from string array to objects const parsedCustomFields = parseObject(customFields); + if (!Array.isArray(parsedCustomFields)) { + throw new ConfigurationError("Custom Fields must be an array of custom field objects"); + } + // Validate custom fields structure parsedCustomFields.forEach((field, index) => { if (!field.id) { - throw new Error(`Custom field at index ${index} is missing required "id" property`); + throw new ConfigurationError(`Custom field at index ${index} is missing required "id" property`); } if (field.value === undefined) { - throw new Error(`Custom field at index ${index} is missing required "value" property`); + throw new ConfigurationError(`Custom field at index ${index} is missing required "value" property`); } });