Filtering and Sorting Custom Fields
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