$filter Parameter
When you retrieve records from MYOB Acumatica by using the contract-based REST API, you use the $filter parameter to specify the conditions that determine which records should be selected from MYOB Acumatica. You use OData URI conventions to specify the value of the parameter.
You can specify multiple conditions for the same field or different fields in a filter by using the AND and OR operators.
When you specify the value of the parameter, you can use the following functions as they are defined in OData:
substringof
startswith
endswith
You can use the following custom function to filter
records by the values of custom fields: cf.<Type name>(f='<View
name>.<Field name>')
, where <Type name>
is the type
of the custom element, <View name>
is the name of the data view that
contains the element, and <Field name>
is the name of the
element.
Example: Simple Condition
To obtain stock item records that have the Active status in MYOB Acumatica, you use the following filter: $filter=ItemStatus eq 'Active'.
Example: Condition on a Linked Entity
To obtain a customer record that has the demo@gmail.com email address, you use the following filter: $filter=MainContact/Email eq 'demo@gmail.com'. (The Email field is defined in a linked entity, which is available through the MainContact property.)
Example: Multiple Conditions
To obtain stock item records that have the Active status in MYOB Acumatica and have been modified later than July 15, 2024, you use the following filter: $filter=ItemStatus eq 'Active' and LastModified gt datetimeoffset'2024-07-15T10%3A31%3A28.402%2B03%3A00'.
System.Net.WebUtility.URLEncode()
method as follows:
WebUtility.UrlEncode(new
DateTimeOffset(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffK"))
.Example: Condition on a Field Not Defined in the Endpoint
Suppose that in an extension of the Default/24.200.001 endpoint, you added the RepairItemType
field to the top-level
StockItem
entity. This field corresponds to the Repair Item
Type custom element, which has been added to the
General tab (Item Defaults section) of the
Stock Items (IN202500) form. If you want to obtain all
records on the Stock Items form for which the value of the
custom Repair Item Type element is Battery, you would use the
following parameter string: $filter=cf.String(f='ItemSettings.UsrRepairItemType') eq
'Battery'.