Recent searches


No recent searches

Custom field as a dropdown list where its elements are taken from external database



Posted Feb 07, 2023

I want to add a custom field to a new ticket creation called "Project Name" and then a dropdown list will have an updated list of all of the active projects from an external data base.

 

I know there's some apps such as Elements and Factbranch to do such a thing but since this is the only option I would like to use I would prefer to develop this option my self. 

I would appreciate any kind of information that will help me start with it.


0

2

2 comments

Ideally you would have some sort of function that can run either on a schedule (cron job) if your database will be updated with new values you want to appear regularly or a function that is triggered when the database is updated. 

The code in the function would include a way to get the data you want from the database (maybe included as an event to the function or maybe a call to your database to get the necessary data) 

Then it would just be a case of updating your target custom fields potential values.

// Get data from database or function event

// If necessary transform data into a format we can use with the Zendesk API

let formattedData = [
{
"name": "Option 1",
"value": "value_for_option_1"
}
...more options here
]

// Send this as a PUT request to yoursubdomain.zendesk.com/api/v2/ticket_fields/{ticket_field_id}

Worth knowing that updating a custom fields options this way will overwrite them so if you have existing options on a ticket field and only want to append these new options from your database you will need to fetch the ticket field before you update it and merge the old options and new options.

This is the approach I would take to accomplish such a task.

1


Hi! Thank you very much for your answer! it helped a lot and gave me a direction for my solution.

Is there an option to host such a function on zendesk's servers as a part of their service?

The only way to do it I can think about right now it's to host it on a cloud such as AWS

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post