Skip to main content

filter-functions

There are predefined filter functions e.g. length(), substring(), substringOf() in the core library, that allow for a wide range of filter expressions:

/*
Fetch all business partners who have a first name shorter than 5 letters
*/
const { businessPartnerApi } = businessPartnerService();
businessPartnerApi
.requestBuilder()
.getAll()
.filter(length(businessPartnerApi.schema.FIRST_NAME).lessThan(5))
.execute(destination);

Filter functions with return type boolean can be used directly as a filter without equal(true). Logically, the two following examples are equivalent to each other:

/*
$filter=startswith(FirstName, 'Bob') eq true
*/
.filter(
startsWith(businessPartnerApi.schema.FIRST_NAME, 'Bob').equal(true)
)

The filter expression can be shortened:

  /*
$filter=startswith(FirstName, 'Bob')
*/
.filter(
startsWith(businessPartnerApi.schema.FIRST_NAME, 'Bob')
)

However, as some services might not support both versions shown above, you might have to choose one of them to fit the target system.