- CRITICAL: Copy pasting the code is not allowed, functions should be utilized
All code reflects the auto-format; always use curly brackets for
if
,for
,while
. See Unified Code Style and How to Auto FormatAvoid api.local, api.global where possible (use a dedicated element, this will help you to trace the logic more easily). Forbidden to use in functions (except special meaning like caching).
- Use
out.SomeElement
prior to (deprecated)api.getElement("SomeElement")
- Use
input.SomeInputName
prior to (deprecated)api.input("SomeInputName")
- Use real data type when declaring the variable instead of
def
. Mandatory use in functions - both parameters and the return type! Use field names in filters or use
api.namedEntities()
if possible- Prevent api.isSyntaxCheck Issues by having AbortSyntaxCheck element in the logic
- Follow the Recommended Logic Structure
Use https://pricefx.atlassian.net/wiki/spaces/DEV/pages/2946629934/Input+Builders
- Smartly use of
@Field
constants (no use for fields, table names, configurator names in customer projects). Mandatory use for important values used in conditions or in accelerators. Use
api.findLookupTableValues("TableName")
instead ofapi.find("MLTVx", ...)
Use one approach for adding item to the list, do not mix the approaches. Recommendation is to use
List << value
prior toList.add(value)
- Use the same approach for accessing List item, do not mix the approaches. Recommendation is to use
List[index]
prior toList.getAt(
index
) - Use the same approach for accessing Map values, do not mix approaches. Recommendation is to use
Map.key
prior toMap[key]
orMap.get(key)
If casting is needed e.g.
?.toBigDecimal()
for amounts (never floats!), do this on the first occurrence of the variable- Use closures (
collect
,collectEntries
,each
,eachWithIndex
,max
,min
,inject
,sort
, etc.) whenever applicable. Note: utilize use of sortBy parameter in api.find() prior tosort()
closure for a better performance. - Use "find" (resp. "query") prefix for the name of a function that is querying PB tables (resp. PA datasources/datamarts) Do not mix data querying and calculation in the functions
- Use the method library alias when calling several Groovy library function in the element or function:
def CurrencyUtils = libs.MainLib.CurrencyUtils
- PERFORMANCE: avoid returning big data in an element. Remember: in Groovy, the expression on the last line is the value returned!
- Split suuuuperlooooong lines.
Initialize
Map
directly. Instead:def map = [:]
map
["key1"] = "
"value1
map
["key
2"] = "
"value2
map
["key
3"] = "
"value3
directly use (and following auto-format):
def map = [ key1: "
",value1
key2
: "
",value2
key3
: "
" ]value3
Analogically, initialize
List
directly. Instead:def list = []
list
<< "value1
"list
<< "value2
"list
<< "value3
"directly use (and following auto-format):
def
list
= [ "value1", "value2", "value3" ]
General
Content
Integrations
App links