Rules engine – Automation use cases
Create compound identifier
If each product must be uniquely identified by a combination of the following fields: "Supplier" (single select) and "Supplier Ref" (single line text).
You need an Identifier to carry the uniqueness constraint.
xml
<Identifiers>
<Identifier key="SUPPLIER-SUPPLIER_REF" index="1" level="PRODUCT">
<Title>Supplier - supplier ref</Title>
</Identifier>
</Identifiers>1
2
3
4
5
2
3
4
5
You need two fields to carry the product value.
xml
<Fields>
<Field key="SUPPLIER" type="SINGLE-SELECT" level="PRODUCT">
<Title>Supplier</Title>
<Options>
<Option key="SUPPLIERX">
<Title>Supplier X</Title>
</Option>
<Option key="SUPPLIERY">
<Title>Supplier Y</Title>
</Option>
</Options>
</Field>
<Field key="SUPPLIER_REF" type="SINGLE-LINE-TEXT" level="PRODUCT">
<Title>Supplier reference</Title>
</Field>
</Fields>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
And a formula to concatenate these two fields value and apply that value to the identifier.
xml
<Formulas>
<Identifier key="SUPPLIER-SUPPLIER_REF">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition source="SUPPLIER" operator="NOT_EMPTY" />
<Condition source="SUPPLIER_REF" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_TEXT">
<Template trim-spaces="true"><![CDATA[{{source("SUPPLIER","key")}}-{{source("SUPPLIER_REF")}}]]></Template>
</Action>
</Rule>
</Identifier>
</Formulas>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
In this particular example:
- You must set a condition on both SUPPLIER and SUPPLIER_REF to not be empty
- The order of the concatenation matters.
Automate volume
If you need to determine a product's volume based on its dimensions, you can automate the calculation, saving yourself the tedious task of doing it manually for each product.
If you have these three dimension fields.
xml
<Fields>
<Field key="WIDTH_CM" type="NUMBER" level="PRODUCT">
<Title>Width</Title>
<Suffix>cm</Suffix>
<Precision>0</Precision>
</Field>
<Field key="HEIGHT_CM" type="NUMBER" level="PRODUCT">
<Title>Height</Title>
<Suffix>cm</Suffix>
<Precision>0</Precision>
</Field>
<Field key="DEPTH_CM" type="NUMBER" level="PRODUCT">
<Title>Depth</Title>
<Suffix>cm</Suffix>
<Precision>0</Precision>
</Field>
<Field key="VOLUME_CM_3" type="NUMBER" level="PRODUCT">
<Title>Volume</Title>
<Suffix>cm3</Suffix>
<Precision>0</Precision>
</Field>
</Fields>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
You can create this formula which will do the computing.
xml
<Formulas>
<Field key="VOLUME_CM_3">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition source="WIDTH_CM" operator="NOT_EMPTY" />
<Condition source="HEIGHT_CM" operator="NOT_EMPTY" />
<Condition source="DEPTH_CM" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_NUMBER">
<Template precision="0" round="CEILING"><![CDATA[{{source("WIDTH_CM")}} * {{source("HEIGHT_CM")}} * {{source("DEPTH_CM")}}]]></Template>
</Action>
</Rule>
</Field>
</Formulas>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Create dependent dynamic lists
You want to model the selectable values on a list field depends on the value selected on another field.
For example if you have a Products table with fields: Supplier and DEEE scale, you want to model that selectable values in DEEE scale depends on the value selected in Supplier.
Based on these supplier and DEEE scale fields.
xml
<Fields>
<Field key="SUPPLIER" type="SINGLE-SELECT" level="PRODUCT">
<Title>Supplier</Title>
<Options>
<Option key="SUPPLIER-1">
<Title>Supplier 1</Title>
</Option>
<Option key="SUPPLIER-2">
<Title>Supplier 2</Title>
</Option>
<Option key="SUPPLIER-3">
<Title>Supplier 3</Title>
</Option>
</Options>
</Field>
<Field key="DEEE_SCALE" type="SINGLE-SELECT" level="PRODUCT">
<Title>DEEE scale</Title>
<Options>
<Option key="DEEE-1">
<Title>DEEE 1</Title>
</Option>
<Option key="DEEE-2">
<Title>DEEE 2</Title>
</Option>
<Option key="DEEE-3">
<Title>DEEE 3</Title>
</Option>
</Options>
</Field>
</Fields>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
You can create this formula which will only display relevant options to users, and warn when unsupported options are used.
xml
<Formulas>
<Field key="DEEE_SCALE">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition source="SUPPLIER" operator="IN">
<Value>SUPPLIER-1</Value>
<Value>SUPPLIER-2</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_SELECTABLE_OPTIONS">
<Value>DEEE-1</Value>
<Value>DEEE-2</Value>
</Action>
</Rule>
<Rule priority="2">
<Conditions>
<Condition-Group>
<Condition source="SUPPLIER" operator="IN">
<Value>SUPPLIER-3</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_SELECTABLE_OPTIONS">
<Value>DEEE-1</Value>
<Value>DEEE-3</Value>
</Action>
</Rule>
</Field>
</Formulas>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Best practice
As you can see above you can group conditions and use rule @priority to model the "If", "else if", "else if"...
You can use this to optimise your conditions, for example if multiple SUPPLIER share the same limitation, then do not create as many rules as you have SUPPLIER values, instead group SUPPLIER values that shares the same limitation in a single rule.
Limit options on single select fields depending on the category
You want to model the selectable values on a list field depends on the item category.
Based on this classification and below field.
xml
<Classifications>
<Classification key="TYPOLOGY">
<Title>Typology</Title>
<Categories>
<Category key="SHOES">
<Title>Shoes</Title>
</Category>
<Category key="T-SHIRT">
<Title>T-shirt</Title>
</Category>
<Category key="SHIRT">
<Title>Shirt</Title>
</Category>
</Categories>
</Classification>
</Classifications>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
xml
<Fields>
<Field key="SIZE" type="SINGLE-SELECT" level="PRODUCT">
<Title>Size</Title>
<Options>
<Option key="39">
<Title>39</Title>
</Option>
<Option key="40">
<Title>40</Title>
</Option>
<Option key="41">
<Title>41</Title>
</Option>
<Option key="42">
<Title>42</Title>
</Option>
<Option key="S">
<Title>S</Title>
</Option>
<Option key="M">
<Title>M</Title>
</Option>
<Option key="L">
<Title>L</Title>
</Option>
<Option key="XL">
<Title>XL</Title>
</Option>
</Options>
</Field>
</Fields>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
You can create this formula which will only display relevant options to users, and warn when unsupported options are used.
xml
<Formulas>
<Field key="SIZE">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition source="TYPOLOGY" operator="EQUALS">
<Value>SHOES</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_SELECTABLE_OPTIONS">
<Value>39</Value>
<Value>40</Value>
<Value>41</Value>
<Value>42</Value>
</Action>
</Rule>
<Rule priority="2">
<Conditions>
<Condition-Group>
<Condition source="TYPOLOGY" operator="IN">
<Value>T-SHIRT</Value>
<Value>SHIRT</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_SELECTABLE_OPTIONS">
<Value>S</Value>
<Value>M</Value>
<Value>L</Value>
<Value>XL</Value>
</Action>
</Rule>
</Field>
</Formulas>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Here we have limited the size that can be selected depending the category.
Best practice
It is a best practice to limit options by categories instead of creating one field by category.
Calculate a status based on criteria on other fields
This can be very useful when you want to model a process. For example you will create a single select Field that represents the current step of the publication of a product on a website.
xml
<Fields>
<Field key="WEB_STATUS" type="SINGLE-SELECT" level="PRODUCT">
<Title>Web status</Title>
<Options>
<Option key="PUBLISHED" color="GREEN">
<Title>Published</Title>
</Option>
<Option key="READY_FOR_WEB" color="BLUE">
<Title>Ready for web</Title>
</Option>
<Option key="TODO" color="ORANGE">
<Title>To do</Title>
</Option>
</Options>
</Field>
</Fields>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
And then this formulas automatically set the current step of the product.
xml
<Formulas>
<Field key="WEB_STATUS">
<Rule priority="1">
<Conditions>
<Condition-Group>
<!-- Assuming that you have a WEB_PUBLICATION_DATE Field that is updated when the product is sent to the web -->
<Condition source="WEB_PUBLICATION_DATE" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_OPTION">
<Value>PUBLISHED</Value>
</Action>
</Rule>
<Rule priority="2">
<Conditions>
<Condition-Group>
<!-- Assuming that you have a conditional formatting that defines what left to be done -->
<Condition source="WEB_COMPLIANCE" operator="EQUALS">
<Value>VALID</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_OPTION">
<Value>READY_FOR_WEB</Value>
</Action>
</Rule>
<Rule priority="3">
<Action type="SET_OPTION">
<Value>TO_DO</Value>
</Action>
</Rule>
</Field>
</Formulas>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Best practice
The rule with priority 1 must be the last step of your process. Therefore the last rule can be used to model a default value when none of the conditions above are met.
Generate a link to related items on another table
When you manage more types of items than just products such as logistics units, spare parts, prices... you may want to easily access to the related items without having to apply the same filters on the other table.
To do so you can create an extra HTML-TEXT field which will be filled with an automatic URL pointing to the related items.
xml
<Field key="UL_LINK">
<Rule priority="1">
<Action type="SET_TEXT">
<Template trim-spaces="true"><![CDATA[
{% set ean = source("EAN") %}
{% set filter = base64_encode("[{\"fieldKey\": \"EAN\",\"operator\": \"equals\",\"criteria\": {\"list\": [\""+ean+"\"]}}]") %}
<a target="_blank" href="https://app.product-live.com/redirect?tableKey=LOGISTICAL_UNIT&filters={{filter}}">link</a>
]]></Template>
</Action>
</Rule>
</Field>1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Here an access link is set up pointing to the LOGISTICS_UNITS table and filtering items based on the EAN target field using the current item EAN value.