Ticket Filter Query Ignoring Custom Field Value

I am attempting to export all Freshdesk Tickets that meet the following criteria.

  • The ticket must be assigned to one of two Ticket Groups
  • The RMA Type must be one of three types.
  • The ticket cannot have an RMA Number assigned to it yet.

The first two criteria are correctly filtering tickets. The sandbox I’m testing in has 182 tickets and the first two criteria select 7. If I add the third criteria, as shown in the following Request URL, I get the same 7 tickets even though 5 of those tickets have a value in the cf_rma_number field.

https://***.freshdesk.com/api/v2/search/tickets?query="cf_rma_number:null AND (group_id:1234567890123 OR group_id:2345678901234) AND (cf_rma_type283115:'Replace now No Return' OR cf_rma_type283115:'Replace now with Return' OR cf_rma_type283115:'Return only')"&page=1

Since the first two criteria are working, I simplified the Request URL to the following for ease of troubleshooting.

https://***.freshdesk.com/api/v2/search/tickets?query="cf_rma_number:null"&page=1

This gives me all 182 tickets. Below is a snippet of the exported tickets showing that it doesn’t matter if cf_rma_number has a value assigned or not.

What am I missing? Any help in resolving this issue will be greatly appreciated.

You will have to use this approach as shown in the API documentation here — Freshdesk

4. Get the list of locked tickets belong to Finance or Marketing sector (Custom Fields: locked, sector).
“(cf_sector:‘finance’ OR cf_sector:‘marketing’) AND cf_locked:true”

curl -v -u yourapikey:X -X GET ‘https://domain.freshdesk.com/api/v2/search/tickets?query=“(cf_sector:‘finance’%20OR%20cf_sector:‘marketing’)%20AND%20cf_locked:true”

If you’re not getting a result for the above query, there’s a chance that the field might have been created recently or it has been moved to a new infrastructure. To query on these custom fields, use ‘custom_string’ instead of the actual field label.

curl -v -u yourapikey:X -X GET ‘https://domain.freshdesk.com/api/v2/search/tickets?query=“custom_string: finance”’

For my own code, I have resorted to doing that with the OR operator so it would look for both custom_string as well as cf.RMA_number with a particular value,
and then additionally validated the cf.RMA_number once the ticket was found.

Hi Dmitry,

Thanks for the reply.

The two criteria looking for specific values are working so I don’t need to use the generic “custom_string” field name.

The part that is not working is the test for cf_rma_number not being populated, “cf_rma_number:null”. I cannot use “custom_string:null” as there are typically many fields on the ticket that are not populated.

Mike