How to Use Column Labels in api.find() and api.stream()

How to Use Column Labels in api.find() and api.stream()

When using the api.find() or api.stream() method in Groovy to search for data, you can reference fields in the fields, sortBy, and filters parameters by either:

  • Their low-level database field name (e.g., sku, clientId, attribute1)

  • Or their configured label (e.g., "Product SKU", "Customer ID")

Using labels requires extra context: When referencing a label in filters (and sometimes in sortBy or fields), you must also provide a discriminator filter to define the entity in which the label is defined. Without this, the method cannot resolve which field the label refers to and may throw an error.

What Is a Discriminator Filter?

A discriminator filter specifies which configuration context to use when resolving a label to a data field. It is essential when you are using a label instead of a database field name in api.find().

Earlier versions than 14.1 may have returned data "by chance" if only one matching label existed.

Prefer using database system field names (e.g., sku, customerId, claimId) for non-attribute fields = fields that have a specific meaning in Pricefx. To be able to use labels for attribute fields, make sure to include the appropriate discriminator filter.

Discriminator Filters by Type Code

Here is a list of required discriminator filters based on the entity (typeCode) you're querying:

Type Codes

Required Discriminator Filter

Type Codes

Required Discriminator Filter

PX, CX, SX

Filter.equal("name", objExtensionName)

MLTV, JLTV

Filter.equal("lookupTable.id", lookupTableId)

PGI, XPGI

Filter.equal("priceGridId", priceGridId)

PLI, XPLI

Filter.equal("pricelistId", pricelistId)

SIMI, XSIMI

Filter.equal("simulationId", simulationId)

MR

Filter.equal("modelId", modelId)

CFO

One of:

  • Filter.equal("typeId", cfTypeId)

  • Filter.equal("moduleCategoryUN", moduleCategoryUN)

CRCP, CRCI1, ..., CRCI12

Filter.equal("conditionRecordSetId", conditionRecordSetId)

CLLI

Filter.equal("claimId", claimId)

def filters = [Filter.equal("ClaimID", "CL-326")] def result = api.find("CLLI", *filters) // Will fail in 14.1+
def filters = [Filter.equal("claimId", "CL-326")] def result = api.find("CLLI", *filters)

Example Using Label With Discriminator

def filters = [ Filter.equal("name", "PX_Margin"), // discriminator Filter.equal("CustomerName", "ACME Inc.") // label ] def result = api.find("PX", *filters)

Troubleshooting

Symptom

Likely Cause

Solution

Symptom

Likely Cause

Solution

"XYZ property is missing on class..."

Label used without discriminator

Use the correct database field or add the required discriminator filter

No results returned unexpectedly

Ambiguous label resolution

Provide discriminator to clarify context or edit the column labels to remove the ambiguity

Works on version 13 but not 14.1 and later

Relying on fallback

Update logic to use correct fields or provide discriminator

See Also

Found an issue in documentation? Write to us.