[Zendesk Support API] How to get the types of the fields properly?Answered
I'd need to generate a form with fields dynamically and, according to their types, I need to choose a component (date picker, list, textbox etc.) for the user to input data.
The problem is: the "list fields" APIs doesn't seem to work as proposed... (https://developer.zendesk.com/rest_api/docs/support/ticket_fields#list-ticket-fields)
First: it only provides a few fields. Not all searchable fields.
Second: it does not provide the field type properly. When I'm listing ticket fields, the type is simply coming as the field name. For example: for "Subject" field, type is coming as "subject", for "Status" field, type is coming as "status".
For me, what would make much more sense would be the types you defined by Zendesk:
- text (default when no "type" is specified)
- tagger (custom dropdown & multi-select dropdown)
If the API does not provide me all the searchable fields and their types, I will have to map all of them manually, which will make my application too rigid.
Do you know how could I get this kind of information dynamically?
Thanks in advance.
I'm not sure I follow
What do you see when you enter yourzendesksite.com/api/v2/ticket_fields.json ?
And what are you expecting to see
Please, take a look at the following fields.
The first one is a system field. The field name is "Assignee" and the type is "assignee'.
The second one is a custom field. The field name is "Numeric-test" and the type is "integer" (makes much more sense).
I was expecting to have any of these following types associated to the field:
The other point is related to the amount of fields retrieved by Ticket Fields API. I get that it only retrieves the fields used on forms. But is there any way for me to get all the searchable fields (https://support.zendesk.com/hc/en-us/articles/203663206#topic_cw3_lb3_mv) of a ticket via API?
The default fields type follow their title
Subject = subject, description = description, status = status, group = group.. etc
All custom fields follow those field types listed above.
Do you have an example of something you'd want to search for?
Hi Felipe. GET /api/v2/ticket_fields.json will return all ticket fields in your instance regardless of what Ticket Form they're used on. As for searching, the link you gave is the best reference for what is searchable.
If you're looking for the ability to search a specific custom field, the 'fieldvalue:' option is the closest there is. It searches all custom fields, however -- you can't currently search only a specific custom field. This is a very popular feature request that has yet to be implemented. Hope this helps move you forward.
PS -- Also thanks McCabe as well for the above answer!
Post is closed for comments.