Overview
The resultFields and sortBy attributes on <filter> elements let you control which fields are returned and in what order. Using resultFields improves performance by requesting only the columns you need, reducing network transfer and memory usage. Using sortBy ensures deterministic ordering, which is important for paginated exports.
Complete XML Examples
resultFields for Selective Data Retrieval
Only fetch the fields you actually need:
<filters>
<filter id="productSkuAndLabel" resultFields="sku,label">
<and/>
</filter>
</filters>
sortBy for Ordered Results
Sort results by a specific field:
<filters>
<filter id="sortedProducts" sortBy="sku">
<and>
<criterion fieldName="label" operator="notNull"/>
</and>
</filter>
</filters>
Combining resultFields and sortBy
<filters>
<filter id="exportFilter" sortBy="id"
resultFields="update_action,Key,Attr1,Op1,Val1,PriceType,AdjType,AdjValue,AmtCurrency,ValidFrom,ValidTo">
<and/>
</filter>
</filters>
resultFields with Criteria
Fetch only specific fields for products matching certain conditions:
<filters>
<filter id="activeProductSummary" resultFields="sku,label,attribute1,attribute2" sortBy="sku">
<and>
<criterion fieldName="attribute1" operator="notNull"/>
<criterion fieldName="label" operator="notNull"/>
</and>
</filter>
</filters>
Incremental Export with LAST_UPDATED Sort
A common pattern for tracking incremental exports — sort by the update timestamp:
<filters>
<filter id="fetchOneRecordForTimestamp" resultFields="LAST_UPDATED" sortBy="LAST_UPDATED">
<and>
<criterion fieldName="LAST_UPDATED" operator="notNull"/>
</and>
</filter>
</filters>
How It Works
-
resultFields— a comma-separated list of field names to include in the fetch response. Only these columns are returned from Pricefx, reducing payload size. -
sortBy— specifies the field to sort results by. The sort direction is ascending by default. -
Both attributes are set directly on the
<filter>element alongside theid. -
At runtime, these values are passed as headers (
filter-resultFieldsandfilter-sortBy) to the Pricefx API, which includes them in the fetch request. -
When using
batchedMode=true,sortByis critical for ensuring consistent pagination — without it, records may be duplicated or skipped across batches.
Common Pitfalls
-
Missing fields in resultFields: If you specify
resultFieldsbut forget a field that your mapper needs, the mapper will receive null for that field. Always ensureresultFieldsincludes all fields referenced in your mapper. -
sortBy with batched mode: When using
batchedMode=true, always specifysortBy. Without deterministic ordering, pagination can produce duplicate or missing records. -
Field name case: Field names in
resultFieldsandsortByare case-sensitive and must match the exact Pricefx field names (e.g.,skunotSKUfor master data, butLAST_UPDATEDfor DataSource fields which may be uppercase). -
Performance:
resultFieldssignificantly reduces response size for objects with many attributes. Always use it when you only need a subset of fields. -
Comma in field names: Field names in
resultFieldsare comma-separated with no spaces. Adding spaces may cause field name mismatches.