Dos and Don'ts
|
Topic |
Tip |
Details |
|---|---|---|
|
api.global over 16 MB not persisted |
❗ Do not put more than 16 MB into the |
|
|
Loading more than 200 rows |
When loading more than 200 rows, it is recommended to use the sortBy field. |
|
|
Storing data for all nodes and api.global |
If you need to store the data for all nodes in the calculation flow (in Distributed Mode), do not use |
|
|
Declaring variables |
❗Do not declare variables inside loops. |
Tips and Notes
|
Topic |
Tip |
Details |
|---|---|---|
|
Best practices for Groovy libraries |
In Libraries, the following is recommended:
|
|
|
Global variables and api.retainGlobal |
If you use global variables, you need to check the settings of
|
|
|
api.global per node |
During the distributed calculations (Price List, LPG, CFS), the process is executed across several server nodes, each sub-process calculating small part of the lines/rows. Each sub-process has its own |
|
|
Maps instead of real objects |
Calculation logic implicitly converts an object to a Map. This is a security feature. In Groovy you always get a map. Returning a specific type would allow you to call something that was not designed to be used in exposed Groovy API. For example, |
|
|
api.addOrUpdate in Test Drive |
When debugging a logic using Test Drive, the This operation will ONLY work in contexts that allow object modification (CFS, CalculationFlow and direct logic execution via JSON API). |
|
|
api.addOrUpdate cannot be used in distributed calculation |
The method However, if you do it safely, it will make sense (addOrUpdate only specific sort of keys, not the same). |
|
|
Why not to use api.boundCall |
|
|
|
Using functions with fields parameter |
When using this form of the function: |
|
|
'float' and 'double' should not be used |
The types 'float' and 'double' should not be used in Groovy because the result of the logic element can ultimately end up in a 'double' which is currently serialized in JSON as a string. Therefore ensure you use 'BigDecimal' whenever dealing with a decimal point number and force the type when initially getting data back from a function call. |
|
|
Return type BigDecimal |
The return type is not guaranteed to be of type BigDecimal. Therefore, always cast to BigDecimal when you read the input value. |