Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Question

In a LPG header logic, it is not possible to use the api.stream method to get all values. When I recalculate the header, its result returns null.

I take these steps:

  1. In the LPG header logic, I create an element and use api.stream to get all price grid items based on the price grid ID and log its result.

  2. I create

    a

    an LPG Type and select the corresponding LPG logic.

  3. In LPG, I recalculate the header and see the log file. The result is null.

...

hiddentrue

...

Answer

api.stream does not work in the syntax check mode and it seems that the header logic is called only in the syntax check mode (which is for generating parameters). There you cannot use api.stream.

To collect data from all line items, you can use api.find – but iterating over all items is a very bad idea. It will be very slow, possibly even unusable. A better option here is aggregation queries; here you can use api.find with the fields parameter which supports aggregation functions too. To overcome the limitation of api.find (results are by default limited to 200), you can use pagination.

For details see Tips on Data Querying with api.find().