Can I filter a product lookup by a PX attribute in Groovy?
Question
Is it possible to filter a product lookup by a PX attribute in Groovy like we can in the UI filters? Something like: api.find("P", Filter.equal("PX.ProductPlant.attribute1", plant))
?
Answer
Yes, it is: Filter.equal(PXNAME__PXCOLUMN, value)
Example
import groovy.transform.Field
@Field final String PRODUCT_PLANT_TABLE_NAME = "ProductPlant"
@Field final String PRODUCT_PLANT_PLANT_ATTRIBUTE = "attribute1"
String tableNamePrefix = "${PRODUCT_PLANT_TABLE_NAME}__"
def typeCode = "P"
def sortBy = "sku"
def fields = ["sku", "attribute1"]
def distinctOnly = true
def filters = [Filter.equal(tableNamePrefix + "${PRODUCT_PLANT_PLANT_ATTRIBUTE}", plant)]
def products = libs.ACELib.LookupUtils.findAllItems(typeCode, sortBy, fields, distinctOnly, filters)
, multiple selections available,
Related content
How can I add products to LPGs by Product Extension filters?
How can I add products to LPGs by Product Extension filters?
More like this
Lookup Tables / Company Parameters (Quick Reference)
Lookup Tables / Company Parameters (Quick Reference)
Read with this
Configurable Lookup Columns Description
Configurable Lookup Columns Description
More like this
How do I get the whole row object within an element of a calculation logic?
How do I get the whole row object within an element of a calculation logic?
Read with this
I cannot use expression as key for joining another table
I cannot use expression as key for joining another table
Read with this
How to Use Column Labels in api.find() and api.stream()
How to Use Column Labels in api.find() and api.stream()
More like this
Found an issue in documentation? Write to us.