Avoid Returning Big Data in Element Result With Display Mode

Why

If an element has Display mode other than Never, then the calculation result gets persisted to an attribute field (according to the mapping). Furthermore, the following entities

  • Pricelist line items

  • PriceGrid line items

  • Calculation Grid line items

  • Simulation line items

  • Rebate records

persist calculation results for all elements that do have Display mode other than Never into a system field allCalculationResults.


If an element returns big amount of data in the result, then persisting such a big value for every line item can cause serious performance or storage problems in the database. Therefore elements should not return big data unless they have a Display mode set to Never.

Groovy specifics

Compared to Java, Groovy does not force you to use return statements. However, omitting this is not a recommended practice, since it can cause unexpected results. Imagine a situation that you do not need the element to return a value (e.g. because you only want to set api.global) and at the end of an element you leave an expression that is evaluated as a big list. It is strongly recommended to include a return statement at the end of each element, even if it is returning nothing. 

If you return e.g. a big List in some element as a temporary result, make sure the element has set Display option set to 'Never'.

def result = ... // some calculation
return result

Explicitly including a return statement to all logic elements is recommended.