Recent searches
No recent searches
Request API search based on ticket custom fields date range
Posted Mar 13, 2024
I'm developing an application that allows users to select dates and insert them into custom fields. My goal is to utilize the Zendesk API to search for tickets based on specific start and end dates, which are represented as custom fields within the tickets. Here's an example of the URL I'm trying for the search query:
https://<domain>.zendesk.com/api/v2/search.json?query=type:ticket custom_field_16896528598683>=2024-04-21 custom_field_16896502734363<=2024-04-25
In this URL, custom_field_16896528598683 represents the start date and custom_field_16896502734363 represents the end date. My objective is to find tickets that either overlap or fall within the specified date range. The purpose of this search is to prevent the assignment of dates to a new ticket if another ticket already includes those dates, ensuring date uniqueness across tickets.
Is it possible to do? Or I need to search all tickets and pass one by one?
0
10 comments
Tipene Hughes
Is this within the context of a ZAF app? If so, you could try getting the values using the client.get method e.g client.get('ticket.customField:custom_field_16896528598683'), saving the returned value to a variable and passing it in to the request.
Let me know if this works for you.
Tipene
0
Vinicius
Tipene Hughes, no, it's not.
It's related with API URL search.
0
Tipene Hughes
0
Tipene Hughes
0
Vinicius
Tipene Hughes, idk if I was clear enough.
Actually, I have a modal with a date selector, and after select those dates (the start date and the end date), I want to search if I have a ticket in conflict if these dates.
Example: Select 04/21 and 07/21, I want to see if I have a ticket with the same date in their custom fields using that URL I've sent.
The URL is not working, because I don't know if it's possible to search custom fields date with <= or >=, that was my question.
I already could solve the problem using tags and other custom fields. Tks!
0
Tipene Hughes
0
Vinicius
Yes, I'm!
My ticket has this following object:
And when I select dates where it can conflict, and try to search, it's not possible:
https://domain.zendesk.com/api/v2/search.json?query=type:ticket custom_field_16896528598683>=2024-04-16 custom_field_16896502734363<=2024-04-22
Or even when I try to intercept them:
https://domain.zendesk.com/api/v2/search.json?query=type:ticket custom_field_16896528598683>=2024-04-16 custom_field_16896528598683<=2024-04-22 custom_field_16896502734363<=2024-04-22 custom_field_16896502734363>=2024-04-16
Could you share your success test, please?
0
Tipene Hughes
0
Vinicius
Tipene Hughes, with the same dates it works (same if you use ":"), try to change your custom field date to 2024-03-20 and 2024-03-24, and do a request again, it won't work, even though the dates are in between those two of URL.
0
Tipene Hughes
I've updated the dates and it's working as expected still.
Can you send me an example screenshot of the requests you're making?
0