How to Find Set of Quotes Containing Given Products

  1. Get all of the quotes (with any necessary filters):

    qs = api.find("Q", i, step, null, 
        Filter.equal("quoteStatus", quoteStatus),
        Filter.equal("workflowStatus", workflowStatus),
        Filter.equal("customerId", customerId))
  2. Get the SKU or list of SKUs that you want to filter on.
  3. Iterate through each line item in each quote. Within each iteration, loop through the list of SKUs and compare it to the quote line item's SKU:

    def quotes = []
    if (skus) {
      for (q in qs) {
        for (li in q.lineItems) {
          if (skus.contains(li.sku)) { 
            quotes.add(q)
            break
          }
        }
      }
    }