How to use filter for custom field and phone field filter in listAllTickets API

How to use custom field filter in ListAllTicketsAPI.

Hi @jibranWipro123,

For filtering the list of tickets, Filter Tickets API can be used. Example 13 shows how a custom field can be used in the query.
Post here if you have any further query on the usage of it.

Hi @Raviraj,
There is an option to apply email filter in ListAllTickets API.
But i don’t see any option to use phone filter.
Can you help me with that?

@jibranWipro123 If you’re looking for filtering tickets based on custom fields, Filter Ticket API will be helpful.

If you’re looking to filter tickets based on the default phone field in List All Tickets API, there are a couple of steps involved to filter the tickets since the phone field is not associated with tickets context. It’s the field associated with the contact as the ticket requester.

List All Tickets API only supports the following two fields in terms of searching based on requester’s profile information.


Steps to filter tickets:

  1. List All Contacts API can be used to filter the contacts based on the phone and mobile field.
  2. Then the tickets can be filtered with the appropriate contact’s identifier (id) as requester_id field.

@Raviraj… Thanks for the reply. But what will be the requester_id considered if more than one contact exists with same phone number because it’s possible to create more than one contact with different email id and same phone number or if in one contact the phone number is not there.
In that case [List All Contacts API] will return two objects having different requester_id.

@jibranWipro123 Yes, it is possible to receive multiple contacts with same phone number since phone field is not a unique field.

What is the use-case to get unique contact for the phone and relevant tickets? I will check if there’s any other way to solve your use-case.

@Raviraj… We have a system where agents create tickets for customers. So to manage ticket for a customer, Agent has to give the phone and see the list of tickets created for that phone/Customer.
But Agent may or may not know the email id of the customer while creating a ticket. If Agent creates two tickets having same phone number with one having an email id and one without an email, then in that case two contacts will be created at FD and at the time of fetching the ListAlltickets, your solution will fail as there would be multiple contacts.

@jibranWipro123 It’s a known challenge since the phone field is not unique field.

When the tickets are being created with only phone and without email, the contact will be created with the phone number (Name field is mandatory in this case).
If this happens from the app, the app can check if there’s an existing contact with the given phone number. It happens the same way from the Freshdesk UI.

So, this check will avoid duplicate contacts with the same phone number.