Find Customer Assignments

This sample shows how you can read and process Customer Assignments in a Price Grid:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 // find the customer assignments associated to this PG (pgId contains the ID of the price grid) def cas = api.find("CA", Filter.equal("assignmentId", pgId)) // process the customer assignments if there are any if (cas) { def filters = [] for (c in cas) { // create a filter from each customer assignment def cg = c.customerGroup filters.add(Filter.equal(cg.customerFieldName, cg.customerFieldValue)) } // put the filters into a single OR filter def filter = filter ? Filter.or(*filters) : null // find the customers who match the filter criteris return api.find("C", filter) }