A variable declaration can be added before a function call as a comma-separated list in curly brackets {}. The scope of the variables declared are only available inside the function parameters that follow.
By default, the three variables 'index', 'item', and 'size' are available within all ITERATE and FILTER function expressions. For more information, see the List Functions section of the Calculated Attribute documentation here.
Variables can be reassigned to another value by normal expression 'var:=expr'. This expression evaluates to the value of 'expr' by assigning the value to variable 'var'.
Examples
The examples below assume a setup including these attributes and products:
|
ATTRIBUTE Type |
ID |
Name |
|---|---|---|
|
Text-validated product attribute |
TEXT1id |
TEXT1 |
|
PRODUCTS ID |
Name |
Parent |
TEXT1id |
|---|---|---|---|
|
P-family-id |
P-family |
Product hierarchy root |
family value |
|
P1id |
P1 |
P-family-id |
p1 value |
|
P2id |
P2 |
P-family-id |
p2 value |
|
P3id |
P3 |
P-family-id |
p3 value |
Copy and paste any of the following examples into the Function Editor and then evaluate against the specified object to get the defined result.
{txt:=prodval('TEXT1id'), pos:=find('p3', txt)} if(pos='N/A', 'no P3', replace(txt, pos, 2, '??')) // = "?? value" evaluated P3; "no P3" evaluated P2
{total:=0, loop:=iterate(listconcatenate(1,4,8,13), 'total:=total+item')} concatenate(total) // = 26
2017, Stibo Systems