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:
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.
I create an LPG Type and select the corresponding LPG logic.
In LPG, I recalculate the header and see the log file. The result is null.
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.