Use the $filter query to select only entries that match an expression specified in the query. Available expressions are Eq (equal to) and Gt (greater than).
Expressions can include references to both properties and literal values. Literal values can include strings (enclosed in single quotes), numbers, boolean values (true or false), or any of the additional literal representations. For a full list of supported properties and literals, along with operators and functions, see here.
eq (equal to)
The Eq expression returns all records where the specified property is equal to a specified literal value.
This query returns contacts where the Type is equal to supplier or customer:
{domain}/{cf_guid}/Contact/?$filter=Type eq 'Customer' or Type eq 'Supplier'
The Eq expression can be used in combination with other filters, such as $orderby (see above). This query returns a set of contacts, sorted by DisplayID, where the Type is equal to Personal and Employee:
{domain}/{cf_guid}/Contact/?$filter=Type eq 'Personal' or Type eq 'Employee'&$orderby=DisplayID
gt (greater than)
The Gt expression returns all records where the specified property is greater than a specified literal value.
This query returns a set of accounts where the Account DisplayID is greater than 5-0000:
{domain}/{cf_guid}/GeneralLedger/Account?$filter=DisplayID gt '5-0000':
The Gt expression can be used in combination with other filters, such as $orderby (see above). This query returns a set of accounts, sorted by Name, where the DisplayID is greater than '4-0000':
{domain}/{cf_guid}/GeneralLedger/Account/?$filter=DisplayID gt '4-0000'&$orderby=Name
any and all operators
Support for 'any' and 'all' operators is now available with OData v3 protocols click here for more information.
The following query returns a customer contact where an email address is equal to 'Davis@yahoo.com.au' from within an array of contact addresses.
{domain}/{cf_guid}/Contact/Customer/?$filter=Addresses/any(x: x/Email eq 'Davis@yahoo.com.au')
Primitive Data Types
To further extend the $filter query option, primitive data types such as DateTime can be implemented, for more information on how to represent this see here
This query returns a set of transactions where the DateOccurred is greater than or equal to 01/4/2013 and less than or equal to 30/04/2013:
{domain}/{cf_guid}/GeneralLedger/JournalTransaction/?$filter=DateOccurred ge datetime'2013-04-01' and DateOccurred le datetime'2013-04-30'
Note: the elements {domain}/{cf_guid} shown in the examples above change depending on your environment and the company file (cf_guid) you are using
Comments
0 comments
Article is closed for comments.