Many times you will need to filter and sort your GETs. For example, you might want all the invoices belonging to a specific account ordered by date. To do this you need to use the search request header. Search requests allow you to filter and sort the returned data on one or more properties of the object. The basic forumula for the search request is:
A filter combines a property, an operator, and a value. Since the filter is an array, elements can be combined using the condition property with a value of 'and'.
The property you want to base the filter on. For a list of elgible filter properties you can use the associated Metadata API.
The filter operator you want to use. Possible values include: eq, notEq, lt, ltEq, gt, gtEq, contains, etc.
The value or range of values to filter the property on. For a list, use comma separated values.
The condition property is used to chain together filters in the array.
Here is an example of a basic filter:
Elements in the filters array are combined using the AND condition and by adding a new element to the array. Building on our previous example, here is an example of filter with two conditions:
The orderBy property allows you to sort the response items by ascending or descending values based on one of the properties. Let's add an orderby condition to our example:
Let's combine two orderBy elements and see what our filter looks like:
Making the Request
Let's add the header to our GET request. The resulting XHR code snippet: