-
Couldn't load subscription status.
- Fork 5.5k
Add Set Custom Ticket Fields action for Zendesk #18502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vunguyenhung
merged 4 commits into
PipedreamHQ:master
from
Afstkla:feat/zendesk-custom-fields
Oct 1, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| 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", | ||
| 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 = parseObject(customFields); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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 ConfigurationError(`Custom field at index ${index} is missing required "id" property`); | ||
| } | ||
| if (field.value === undefined) { | ||
| throw new ConfigurationError(`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}`); | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return response; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) { | ||
| return {}; | ||
| } | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.