Skip to main content

Filtering and Sorting Custom Fields

info

The new filtering and sorting methods only exist in API versions starting with 2024-01-01. They can be identified by the response, which returns an object with pagination data, applied filters and sorts, and the array of records in the records attribute.

Custom field sorting and filtering is not available on new endpoints at this time.

Custom Fields require their own special filters.

To tell Fleetio that you're searching for a Custom Field, your field name needs to be in the following format:

custom_field_CUSTOM_FIELD_NAME_PREDICATE

  • CUSTOM_FIELD_NAME is the name of your custom field in Fleetio, for example: invoice_number
  • PREDICATE is any predicate from the following list:
    • eq (Equals)
    • not_eq (Does not equal)
    • cont (Contains)
    • not_cont (Does not contain)
    • start (Starts with)
    • end (Ends with)
    • blank (Record has or does not have Custom Field set. Use 0 or 1 for values. More details below.)

Putting it all together

If you wanted to search for a Work Order with a Custom Field named invoice_number containing the string "123", you would make the following call to the API:

https://secure.fleetio.com/api/v1/work_orders?q[custom_field_invoice_number_cont]=123

To use the blank predicate for Custom Fields, use 0 or 1 as values. For example, q[custom_field_invoice_number_blank]=0 indicates that the Custom Field invoice number is not blank, and q[custom_field_invoice_number_blank]=1 indicates that the Custom Field invoice number is blank

Checkbox Custom Field types

Checkbox (boolean) Custom Field values are stored as "true" or "false" strings. For example, if you wanted to search Work Orders for a boolean custom field named paid, you would make the following call:

https://secure.fleetio.com/api/v1/work_orders?q[custom_field_paid_eq]=true