Conditional Examples
These examples do not require specific object data to produce the defined result.
For function syntax information and more detailed use cases, refer to the Conditional Functions documentation here.
Copy and paste any of the Value Template text below into the Function Editor, select any object, and click the Evaluate button to display the defined Result.
Value Template |
Result |
Notes |
---|---|---|
if (1=1, 'true', 'false')
|
true |
1 does equal 1 so the first result is returned |
if (not(1=1), 'true', 'false')
|
false |
NOT changes 'False to True' or 'True to False,' so the second result is returned |
if (exact('hello','you'), 'true', 'false')
|
false |
EXACT requires that the two values match, so the second result is returned |
if (or(1=1,exact('hello','you')), 'true', 'false')
|
true |
OR allows either 1=1 or an exact match, so the first result is returned |
if (and(1=1,exact('hello','you')), 'true', 'false')
|
false |
AND requires both functions to be true, so the second result is returned |
Testing Using And, Or, and Not Functions
The example value templates require the attributes and values defined in the following table:
ATTRIBUTE Type |
ID |
Name |
AttrDesc |
---|---|---|---|
Number-validated product attribute with length units |
NUMBER1id |
NUMBER1 |
NUMBER1 description |
Text-validated product attribute |
TEXT1id |
TEXT1 |
TEXT1 description |
The example value templates require the products and values defined in the following table:
PRODUCTS ID |
Name |
Parent |
TEXT1id |
NUMBER1id |
---|---|---|---|---|
P1id |
P1 |
P-family-id |
p1 value |
4 m |
After creating the data above, copy and paste any of the Value Template text below into the Function Editor. Select the Object identified and click the Evaluate button to display the defined Result.
Value Template |
Object |
Result |
Notes |
---|---|---|---|
and((value('TEXT1id')= 'p1 value'), (value('NUMBER1id')= '4')) |
P1id |
1 |
Both conditions are true |
and((value('TEXT1id')= 'p0 value'), (value('NUMBER1id')= '3')) |
P1id |
0 |
Both conditions are false |
or((value('TEXT1id')= 'p1 value'), (value('NUMBER1id')= '4')) |
P1id |
1 |
One condition is true |
or((value('TEXT1id')= 'p0 value'), (value('NUMBER1id')= '3')) |
P1id |
0 |
Both conditions are false |
not(value('TEXT1id')= 'p1 value')) // = 0 (FALSE) evaluated P1id |
P1id |
0 |
Condition is true, NOT results in a return of 'false ' |
not(value('TEXT1id')= 'p0 value')) // = 1 (TRUE) evaluated P1id |
P1id |
1 |
Condition is false, NOT results in a return of 'true' |
Testing Using If Function
These example calculated attributes are written to use a product with the attribute data defined in the following table.
Attribute |
Length |
Width |
PowerCordLength |
Value |
75 cm |
75 cm |
2 m |
Copy and paste any of the Value Template text below into the Function Editor, select the Object with the defined data, and click the Evaluate button to display the Result.
Value Template |
Result |
Notes |
---|---|---|
if(prodval('Length') = prodval('Width'), 'Product is Square.','Product is Oblong.') |
Product is Square. | Length does equal Width, so the first result is returned |
if(prodval("PowerCordLength") > 0,concatenate ('A ', prodvalsimple("PowerCordLength"), ' power cord is included.'), 'Power cord not included.') |
A 2 m power cord is included. |
2 is greater than 0, so the first result is returned The value of '2 m' is extracted via the function PRODVALSIMPLE(“PowerCordLength”), and the surrounding text to that value was accomplished using the CONCATENATE function. If it is desired that the unit for meters (m) is not situated immediately after the value '2', then the function of PRODVALSIMPLE is not appropriate, but the following formula could be used instead. |
if(prodval("PowerCordLength") > 0,concatenate ('A ', prodval("PowerCordLength"), produnit("PowerCordLength"), ' power cord is included.'), 'Power cord not included.') |
A 2 m power cord is included. | The value of '2' is extracted via the function PRODVAL(“PowerCordLength”), and the unit of 'm' was extracted separately via the function PRODUNIT(“PowerCordLength”). |
Displaying a Value Using If Function
This example calculated attribute is written to use products with the attribute data defined in the following table.
|
Weight |
P2(P2id) |
75 |
P3(P3id) |
23 |
P4(P4id) |
101 |
Copy and paste the Value Template text below into the Function Editor, select the Object identified, and click the Evaluate button to display the Result.
Value Template |
Object |
Result |
---|---|---|
If (value('Weight') > 100, 'A', if (value('Weight') < 50, 'B', 'C')) |
P2id |
C |
If (value('Weight') > 100, 'A', if (value('Weight') < 50, 'B', 'C')) |
P3id |
B |
If (value('Weight') > 100, 'A', if (value('Weight') < 50, 'B', 'C')) |
P4id |
A |