Rules engine / Import rules
Import rules of the rules engine.
Task name:
Examples
json
{
"name": "rules-engine-import-rules",
"taskReferenceName": "import target table rules",
"description": "The business description of the task",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"request": "${previousTask.output.file}"
}
}1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
Definition
| Property | Type | Required | Description |
|---|---|---|---|
| The name (or type) of the task | |||
| The unique name of the task in your job. It is used to reference this task in the workflow. | |||
| The functional description of this task in your job. | |||
The type of the task. It must be SUB_WORKFLOW. | |||
| : | true: the job continues if there is an error on this task. false: the job fails. | ||
| Input parameters of the task. See below |
Inputs Parameters
| Property | Type | Required | Description |
|---|---|---|---|
| See below. | |||
| The account key of the partner owning the shared table. | |||
| : | Default: falseWhen set to true, the report generation is skipped and thus the report is not available in the output parameters. | ||
| : | Default: info It defines the log level to be recorded in the report. error < warning < info < debug |
Input - request
xml
<Rules-Engine table="target_table" account="f4784206-9584-42a8-b36b-7f263d9af96a">
<Source-Tables>
<Table key="source_table_1" source-identifier="gencod" target-identifier="ean13" />
<Table key="source_table_2" source-identifier="gencod" target-identifier="ean13" />
<Table key="source_table_3" source-identifier="gencod" target-identifier="ean13" />
</Source-Tables>
<Rules>
<Identifier key="sku" source-table="source_table_1">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="sku" operator="EMPTY" />
<Condition source="articleNumber" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_TEXT">
<Copy source="color" use="title" lang="fra" remove-carriage-returns="true" trim-spaces="true" />
</Action>
</Rule>
</Identifier>
<Classification key="typology" source-table="source_table_1">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="typology" operator="EMPTY" />
<Condition source="erp" operator="NOT_EMPTY" />
<Condition source="erp" operator="IN">
<Value>laveVaisselle</Value>
<Value>frigo</Value>
<Value>réfrigérateur</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_CATEGORY">
<HashMap source="erp">
<Entry source="laveVaisselle" target="dishwasher"/>
<Entry source="frigo" target="fridge"/>
<Entry source="réfrigérateur" target="fridge"/>
</HashMap>
</Action>
</Rule>
<Rule priority="2" name="Perceuse si type est sans fil">
<Conditions>
<Condition-Group>
<Condition source="erp" operator="EQUALS">
<Value>Perceuse</Value>
</Condition>
<Condition source="type" operator="EQUALS">
<Value>sansFil</Value>
</Condition>
<Condition target="typology" operator="EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_CATEGORY">
<Value>cordlessDrill</Value>
</Action>
</Rule>
<Rule priority="3" name="Perceuse si type est avec fil">
<Conditions>
<Condition-Group>
<Condition source="erp" operator="EQUALS">
<Value>Perceuse</Value>
</Condition>
<Condition source="type" operator="EQUALS">
<Value>avecFil</Value>
</Condition>
<Condition target="typology" operator="EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_CATEGORY">
<Value>wiredDrill</Value>
</Action>
</Rule>
</Classification>
<Field key="titleEn" source-table="source_table_1">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="titleEn" operator="EMPTY" />
<Condition target="label" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_TEXT">
<Copy target="label" remove-html="true" remove-carriage-returns="true" trim-spaces="true" />
<!-- If label is a single_select extract parameter is required, if we extract title lang is required -->
<!-- <Copy-Text-From target="label" extract="title">cordlessDrill</Copy-Text-From> -->
<!-- <Copy-Text-From extract="title" lang="fra">cordlessDrill</Copy-Text-From> -->
</Action>
</Rule>
</Field>
<Field key="descriptionEn" source-table="source_table_3">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="descriptionEn" operator="EMPTY" />
<Condition target="label" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_TEXT">
<Copy target="label" remove-html="true" remove-carriage-returns="true" trim-spaces="true" />
</Action>
</Rule>
<Rule priority="2">
<Conditions>
<Condition-Group>
<Condition target="descriptionEn" operator="EMPTY" />
<Condition target="descriptionEn" operator="EQUALS">
<Value>specific value</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_TEXT">
<Value>Default</Value>
</Action>
</Rule>
</Field>
<Field key="brand">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="brand" operator="EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_OPTION">
<Value>eberhardt</Value>
</Action>
</Rule>
</Field>
<Field key="description" source-table="source_table_1">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="description" operator="EMPTY" />
<Condition source="composition" operator="NOT_EMPTY" />
<Condition source="matière" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_TEXT">
<Template trim-spaces="true">
<![CDATA[
<b>Composition</b>
<br></br>
{{source("composition")}}
<br></br>
<br></br>
<b>Matières</b>
<br></br>
{{source("matière")}}
]]>
</Template>
</Action>
</Rule>
</Field>
<Field key="face" source-table="source_table_1">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="face" operator="EMPTY" />
<Condition source="vueDeFace" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_IMAGE">
<Copy source="vueDeFace" width-px="1000" height-px="1000" quality="90" extension="jpg" />
</Action>
</Rule>
</Field>
<Field key="productWidth" source-table="source_table_1">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="productWidth" operator="EMPTY" />
<Condition source="largeurDuProduit" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_NUMBER">
<Copy source="largeurDuProduit" precision="2" round="UP" />
</Action>
</Rule>
</Field>
<Field key="priceTTC" source-table="source_table_1">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="priceTTC" operator="EMPTY" />
<Condition target="priceHT" operator="NOT_EMPTY" />
<Condition source="tva" operator="EQUALS">
<Value>19.6</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_NUMBER">
<Template precision="2" round="DOWN">
<![CDATA[
{{source("prixHT")}} * 19.6
]]>
</Template>
</Action>
</Rule>
</Field>
<Field key="power" source-table="source_table_1">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="power" operator="EMPTY" />
<Condition target="puissance@laveVaisselle" operator="NOT_EMPTY" />
<Condition source="erp" operator="EQUALS">
<Value>laveVaisselle</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_NUMBER">
<Copy source="puissance@laveVaisselle" precision="2" round="UP" />
</Action>
</Rule>
<Rule priority="2">
<Conditions>
<Condition-Group>
<Condition target="power" operator="EMPTY" />
<Condition target="puissance@frigo" operator="NOT_EMPTY" />
<Condition source="erp" operator="EQUALS">
<Value>frigo</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_NUMBER">
<Copy source="puissance@frigo" precision="2" round="UP" />
</Action>
</Rule>
<Rule priority="3">
<Conditions>
<Condition-Group>
<Condition target="power" operator="EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_NUMBER">
<Value>10</Value>
</Action>
</Rule>
</Field>
<Field key="color" source-table="source_table_1">
<Rule priority="1">
<Action type="SET_OPTION">
<HashMap source="couleur">
<Entry source="rouge" target="red" />
<Entry source="bordeaux" target="red" />
<Entry source="magenta" target="red" />
<Entry source="bleu" target="blue" />
<Entry source="azure" target="blue" />
<Entry source="petrol" target="blue" />
</HashMap>
</Action>
</Rule>
</Field>
<Field key="length" source-table="source_table_1">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition source="typology" operator="EQUALS">
<Value>phone</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_NUMBER">
<Copy source="longueur@telephone" />
</Action>
</Rule>
<Rule priority="2">
<Conditions>
<Condition-Group>
<Condition source="typology" operator="EQUALS">
<Value>breadMaker</Value>
</Condition>
</Condition-Group>
</Conditions>
<Action type="SET_NUMBER">
<Copy source="longueur@machineAPain" />
</Action>
</Rule>
</Field>
</Rules>
</Rules-Engine>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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
File structure
xml
<Rules-Engine table="PRODUCTS_RETAILERX" account="89h6797-2990a-345s78-90gh6-8klm89jlm78">
<Source-Tables />
<Rules />
</Rules-Engine>1
2
3
4
2
3
4
| XPath | Description | Occurs |
|---|---|---|
Rules-Engine | The root element. | 1 |
@table | Target table key | 1 |
@account | Target account key | 1 |
Source-Tables | List of source tables | 1 |
Rules | All rules for each attributes | 1 |
Source tables
Source-Tables make it possible to reconcile items from several tables, by linking the identifiers of these tables to each other.
Example: the EAN identifier of my product table is equivalent to the EAN 13 identifier of the table that was shared with me by my partner.
xml
<Rules-Engine table="PRODUCTS_RETAILERX" account="89h6797-2990a-345s78-90gh6-8klm89jlm78">
<Source-Tables>
<Table key="PRODUCTS_BRANDX" source-identifier="EAN_13" target-identifier="EAN" />
</Source-Tables>
<Rules />
</Rules-Engine>1
2
3
4
5
6
2
3
4
5
6
| XPath | Description | Occurs |
|---|---|---|
Table | For each source table | 1..* |
@key | Source table key | 1 |
@source-identifier | Source identifier key | 1 |
@target-identifier | Target identifier key | 1 |
@account | The account key that owns the source table. Required only when that table belongs to an account other than the one running the task - a table shared with you by a partner, for instance. Omit it for your own tables. | 0..1 |
Uniqueness and access rules
Each Table entry creates one link between the target table and a source table. The entries are processed in file order, and each entry is validated on its own.
- One link per level of the target table, per source table. If two
Tableentries name the same source table and theirtarget-identifierattributes belong to the same level of the target table, the first entry is imported and the second is rejected. Since a target identifier belongs to a single level, this also means the sametarget-identifiercannot be linked to two different identifiers of the same source table. - On a target table with several levels, the same source table may be listed more than once, provided each entry points to a
target-identifieron a different level. - The source table must be one your account can access - a table you own, or a table a partner has shared with you (name its owner in
@account). A source table you cannot access is rejected. source-identifierandtarget-identifiermust each name an active identifier of the source and target table respectively. An archived identifier is treated as if it did not exist.- Because the file is exhaustive for a given target table, these rules are evaluated against the entries of the file being imported, not against the links created by a previous import: the previous set of links is replaced.
A Table entry rejected for one of the reasons below does not stop the import - the other entries and the rules are still processed, and the rejection is reported in the execution report.
| Code | Severity | Raised when |
|---|---|---|
DUPLICATE_SOURCE_ON_TARGET_TABLE | error | An earlier Table entry in the same file already links that source table to this level of the target table. The duplicate entry is not imported. |
SOURCE_TABLE_DOES_NOT_EXIST | error | Your account has no access to the table named in @key (owned by @account, when set). The Table entry is not imported. The same code is used for the target table Rules-Engine@table when it is missing or not accessible - in that case nothing at all is imported, so check @table first when you see it. |
SOURCE_IDENTIFIER_DOES_NOT_EXIST | error | @source-identifier is missing, or is not an active identifier of the source table. The Table entry is not imported. |
TARGET_IDENTIFIER_DOES_NOT_EXIST | error | @target-identifier is missing, or is not an active identifier of the target table. The Table entry is not imported. |
NOT_FOUND | error | @account names an account key that does not exist. The message is a bare nothing found and names nothing, so check the account key yourself. The Table entry is not imported. |
An unresolvable source table is not reported
A missing @key, and a @key that names no table under the account it is resolved against, are handled differently from every case above. That entry and every Table entry after it are skipped, and no log says so - the failure is recorded without an error code, and codeless entries are left out of the report file. What you observe is allRulesImported: NO, rules missing wherever their source table was never linked, and a report listing only those knock-on FIELD_SOURCE_INACCESSIBLE rejections. Check the keys and accounts in Source-Tables first when a report looks inconsistent with the file you sent.
Multi-level tables
A multi-level table can be the target of mapping rules, and a mapping rule can use a multi-level table as its source. Nothing is refused merely for being multi-level, and nothing has to be enabled.
Levels do, however, constrain what a link can declare and what a rule can reach. Each Table link joins one level of the source table - the level of its source-identifier - to one level of the target table - the level of its target-identifier. On a multi-level target table the same source table can therefore be linked once per level:
xml
<Rules-Engine table="PRODUCTS_RETAILERX" account="89h6797-2990a-345s78-90gh6-8klm89jlm78">
<Source-Tables>
<Table key="PRODUCTS_BRANDX" source-identifier="MODEL" target-identifier="PRODUCT_CODE" />
<Table key="PRODUCTS_BRANDX" source-identifier="EAN_13" target-identifier="EAN" />
</Source-Tables>
<Rules />
</Rules-Engine>1
2
3
4
5
6
7
2
3
4
5
6
7
For rules that declare a source-table, the levels then decide what is reachable:
- Rules can be created on an element that sits at the joined target level or on a level below it. If no link to that source table joins the element's level or one of its parent levels, none of the rules on that element are imported and the report carries
FIELD_SOURCE_INACCESSIBLE. - Inside a rule, a field referenced on the target side must sit at the joined target level or above it. A deeper field is rejected with
RULE_TARGET_FIELD_INACCESSIBLEand that rule is not created; the other rules on the element are still imported. - Likewise, a field referenced on the source side must sit at the level of the link's
source-identifieror above it. A deeper field is rejected withRULE_SOURCE_FIELD_INACCESSIBLEand that rule is not created.
These three constraints compare level depths, so on a single-level table they can never apply.
The task does not check that the levels are consistent
Nothing requires the two identifiers of a link to sit at comparable depths. Linking a level 1 identifier of the source table to a level 2 identifier of the target table - and, in the same file, a level 3 identifier to a level 1 one - is accepted and reported as a success, but it will reconcile items that have nothing to do with each other. Check the levels of the identifiers you link yourself.
Rules
Info
The examples below correspond to the examples presented in the Rules Engine documentation. Make sure you read this documentation carefully to understand these examples.
Rules can be created for each target attribute Identifier | Classification | Field of the target table. For example for a target Field the main structure will be:
xml
<Rules-Engine table="PRODUCTS_RETAILERX" account="89h6797-2990a-345s78-90gh6-8klm89jlm78">
<Source-Tables>
<Table key="PRODUCTS_BRANDX" source-identifier="EAN_13" target-identifier="EAN" />
</Source-Tables>
<Rules>
<Field key="LABEL" source-table="PRODUCTS_BRANDX">
<Rule priority="1" name="">
<Conditions />
<Action />
</Rule>
</Field>
</Rules>
</Rules-Engine>1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
| XPath | Description | Occurs |
|---|---|---|
Rules/Identifier | For each target Identifier | 0..5 |
Rules/Classification | For each target Classification | 0..5 |
Rules/Field | For each target Field | 0..* |
Regardless the attribute type you have to set the following attributes:
| XPath | Description | Occurs |
|---|---|---|
@key | Key of the target Identifier | Classification | Field | 1 |
@source-table | Specify the source table key for the curent field. Only one source table can be specified for a given field. The key must refer to a table defined in the Source-Tables section. This property is mandatory if the skip attribute is not set to true and the number of rules is greater than 0. | 0..1 |
@source-account | The account key that owns the table named in @source-table. Required only when that table belongs to an account other than the one running the task. | 0..1 |
@skip | Set true to skip this field while processing the rules. It will be also marked as skipped in the UI. If a field is ignored, the rules associated with it are not executed. If false or absent, the rules on the field are executed. | 0..1 |
Rule | For rule | 0..1000 |
Rule/@priority | You can have multiple rules on a field, they will be executed by priority. | 1 |
Rule/@name | You can give a name to your rule. | 0..1 |
Rule/Conditions | Defines in which conditions the rule must be executed. | 0..1 |
Rule/Action | Defines the action that must be done. Actions available depends on the data type of the target. | 1 |
A complete example would be:
xml
<Rules-Engine table="PRODUCTS_RETAILERX" account="89h6797-2990a-345s78-90gh6-8klm89jlm78">
<Source-Tables>
<Table key="PRODUCTS_BRANDX" source-identifier="EAN_13" target-identifier="EAN" />
</Source-Tables>
<Rules>
<Field key="LABEL" source-table="PRODUCTS_BRANDX">
<Rule priority="1" name="Automate Label from Title">
<Conditions>
<Condition-Group>
<Condition source="TITLE" operator="NOT_EMPTY" />
<Condition target="LABEL" operator="EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_TEXT">
<Copy source="TITLE" trim-spaces="true" />
</Action>
</Rule>
</Field>
<Field key="DESCRIPTION" skip="true" />
</Rules>
</Rules-Engine>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Example:
If
titleEnin the destination table is empty andlabelin the destination table is non-empty Then copy intitleEnthe value oflabel(which also belongs to the target table, in this case we are copying fields within the same table). Before copying the value, remove the spaces at the beginning and end of the string (trim-spaces="true")
xml
<Field key="titleEn" source-table="PRODUCTS_BRANDX">
<Rule priority="1">
<Conditions>
<Condition-Group>
<Condition target="titleEn" operator="EMPTY" />
<Condition target="label" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>
<Action type="SET_TEXT">
<Copy target="label" trim-spaces="true" />
</Action>
</Rule>
</Field>1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
Conditions
xml
<Conditions>
<Condition-Group>
<Condition source="TITLE" operator="NOT_EMPTY" />
<Condition target="LABEL" operator="EMPTY" />
</Condition-Group>
</Conditions>1
2
3
4
5
6
2
3
4
5
6
| XPath | Description | Occurs |
|---|---|---|
Condition-Group | Within a Condition-Group each Condition is interpreted with a AND logic. If you have several Condition-Group they are interpreted with a OR logic. | 1..* |
Condition | For each Condition | 1..* |
Condition/@source | The key of the source Identifier | Classification | Field | 1 |
Condition/@target | The key of the target Identifier | Classification | Field | 1 |
Condition/@operator | ENUM that depends on the type of the attribute. See below. | 1 |
Condition/Value | See details below | 0..* |
Condition/@use | Used to specify the value to be used for the condition. If the use attribute is not specified, the value of the source or target (depending on what is specified for target or source) is used. See below for the different possible values depending on the type of source or target. | 0..1 |
Key points:
- Conditions can be set on source or target attributes
- You can have multiple conditions on the same attribute
- Conditions in a group is interpreted with a AND logic, every condition must be true for the group to be true
- You can have multiple groups, they are interpreted with a OR logic, at least one group must be true
- Nesting group of conditions is not allowed
Examples:
In the example below, titleEn must be empty AND label must be non-empty.
xml
<Conditions>
<Condition-Group>
<Condition target="titleEn" operator="EMPTY" />
<Condition target="label" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>1
2
3
4
5
6
2
3
4
5
6
In the example below, titleEn must be empty AND label must be non-empty, or description must be non-empty.
In other words: (titleEn == "" && label !== "") || description !== ""
xml
<Conditions>
<Condition-Group>
<Condition target="titleEn" operator="EMPTY" />
<Condition target="label" operator="NOT_EMPTY" />
</Condition-Group>
<Condition-Group>
<Condition target="description" operator="NOT_EMPTY" />
</Condition-Group>
</Conditions>1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
IDENTIFIER conditions
| Operator | Description | Additional parameters |
|---|---|---|
EMPTY | Is empty | None |
NOT_EMPTY | Is not empty | None |
CONTAINS | Contains a value (insensitive to case and accents) | Need a Value see below |
EQUALS | Strictly equals to a value (case sensitive and accents) | Need a Value see below |
STARTS_WITH | Starts with a value (case sensitive and accents) | Need a Value see below |
ENDS_WITH | Ends with a value (case sensitive and accents) | Need a Value see below |
IN | Equals to one of the values (case sensitive and accents) | Need a Value see below |
NOT_IN | Is equals to none of the values (case sensitive and accents) | Need a Value see below |
xml
<Condition target="EAN_13" operator="IN">
<Value>1234567890123<Value>
<Value>1234567890124<Value>
</Condition>1
2
3
4
2
3
4
CLASSIFICATION, SINGLE-SELECT, MULTIPLE-SELECT, MULTIPLE_SELECT_QUANTIFIED, MULTIPLE-SELECT-QUANTIFIED-WITH-COMMENTS conditions
| Operator | Description | Additional parameters |
|---|---|---|
EMPTY | Is empty | None |
NOT_EMPTY | Is not empty | None |
EQUALS | Strictly equals to a value | Need a Value see below. The value is the key of the Option/Category. |
NOT_EQUALS | Not equals to a value | Need a Value see below. The value is the key of the Option/Category. |
IN | Equals to one of the value | Need a Value see below. The value is the key of the Option/Category. |
NOT_IN | Is equals to none of the values | Need a Value see below. The value is the key of the Option/Category. |
xml
<Condition target="COLOR" operator="NOT_IN">
<Value>RED</Value>
<Value>BLUE</Value>
</Condition>1
2
3
4
2
3
4
SINGLE-LINE-TEXT, LONG-TEXT, HTML-TEXT conditions
| Operator | Description | Additional parameters |
|---|---|---|
EMPTY | Is empty | None |
NOT_EMPTY | Is not empty | None |
CONTAINS | Contains a value (insensitive to case and accents) | Need a Value see below |
EQUALS | Strictly equals to a value (case sensitive and accents) | Need a Value see below |
STARTS_WITH | Starts with a value (case sensitive and accents) | Need a Value see below |
ENDS_WITH | Ends with a value (case sensitive and accents) | Need a Value see below |
xml
<Condition target="LABEL" operator="STARTS_WITH">
<Value>Ipod - <Value>
</Condition>1
2
3
2
3
NUMBER, DATE, DATE-TIME conditions
| Operator | Description | Additional parameters |
|---|---|---|
EMPTY | Is empty | None |
NOT_EMPTY | Is not emptu | None |
LESS_THAN | Is less than a value | Need a Value see below |
LESS_THAN_OR_EQUAL | Is less than or equal to a value | Need a Value see below |
GREATER_THAN | Is greater than a value | Need a Value see below |
GREATER _THAN_OR_EQUAL | Is greater than or equal to a value | Need a Value see below |
EQUALS | Strictly equals | Need a Value see below |
xml
<Condition target="PRICE" operator="LESS_THAN">
<Value>100.4<Value>
</Condition>1
2
3
2
3
- For NUMBER, the value must be a number. So 0.3 is valid, 0,3 is not valid.
- For DATE and DATE-TIME the value must follow YYYY-MM-DDTHH:mm:ss.sssZ, you can read more here: view link
Suffix conditions
To apply a condition on a NUMBER suffix, you need to specify that you want to use that unit and not the value.
| Operator | Description | Additional parameters |
|---|---|---|
EMPTY | Is empty | None |
NOT_EMPTY | Is not empty | None |
EQUALS | Is equal to a suffix key | Need a Value see below |
NOT_EQUALS | Is different from a suffix key or empty | Need a Value see below |
CONTAINS | Contains a part of the suffix key | Need a Value see below |
STARTS_WITH | Starts with a part of the suffix key | Need a Value see below |
ENDS_WITH | Ends with a part of the suffix key | Need a Value see below |
xml
<Condition source="PRICE" use="SUFFIX_KEY" operator="EQUALS" >
<Value>EURO</Value>
</Condition>1
2
3
2
3
IMAGE, ATTACHMENT conditions
| Operator | Description | Additional parameters |
|---|---|---|
EMPTY | Is empty | None |
NOT_EMPTY | Is not empty | None |
Actions
There can only be one action done on the target field only. There are different types of actions depending on the type of target field.
SINGLE-LINE-TEXT, LONG-TEXT, HTML-TEXT actions
Then the Action/@type must be SET_TEXT. Then you can use these actions:
Copy SINGLE-LINE-TEXT, LONG-TEXT, HTML-TEXT
xml
<Action type="SET_TEXT">
<Copy source="color" use="title-local" lang="fra" remove-carriage-returns="true" trim-spaces="true" />
</Action>1
2
3
2
3
| XPath | Description | Occurs |
|---|---|---|
@source | The key of the Identifier | Classification | Field | 1 |
@use | If the source is a Classification or a List, you must define if you want to use title | title-local | key | 0..1 |
@lang | If you have set @use=title-local then you must define which language must be used. If the language does not exist, a fallback is done on the default language. | 0..1 |
@remove-carriage-returns | Set true to remove carriage returns | 0..1 |
@trim-spaces | Set true to trim spaces | 0..1 |
- If the source is of the Multiple select type, the options are joined by
; - If the source is of the Multiple select quantified type, the options are joined by
;and we apply the following template:[quantity]: [value] - If the source is of the Multiple select quantified with comments type, the options are joined by
;and we apply the following template:[quantity]: [value], [comment]
Value of SINGLE-LINE-TEXT, LONG-TEXT, HTML-TEXT
xml
<Action type="SET_TEXT">
<Value>Hello world</Value>
</Action>1
2
3
2
3
You can use this to set a default value.
Template on SINGLE-LINE-TEXT, LONG-TEXT, HTML-TEXT
This actions allows to concatenate texts.
xml
<Action type="SET_TEXT">
<Template trim-spaces="true" engine="twig.1">
<![CDATA[
<b>Composition</b>
<br></br>
{{source("COMPOSITION")}}
<br></br>
<br></br>
<b>Materials</b>
<br></br>
{{source("MATERIALS","title")}}
]]>
</Template>
</Action>1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
The notation {{source}} allows to reference a source Identifier | Classification | Field. The first value is the key of the attribute.
- If the key contains a double quote, then it must doubled:
source("MORE_THAN_100""_SCREEN") - The second parameter is used for Classifications or List, you can choose between
title|title-local|key - The third parameter is to set the language if you have set
title-localfor the second parameter
The <Template> node accepts the following attributes:
trim-spaces(optional): settrueto trim spaces before and after the result string, before writing it into the target cell.engine(optional): choose the template engine used to evaluate the Twig expression.twig.1(default): full feature set with Product-Live custom functions (source,target,loadChildren,base64_*, etc.).twig.2: lighter engine with only core Twig features, optimized for performance on tables with many template rules.
For a user-oriented description of template engines, see the Rules Engine templates guide.
Best practice
Do the concatenation only if all attributes used are not empty. For this use the conditions.
NUMBER actions
Then the Action/@type must be SET_NUMBER. Then you can use these actions:
Copy NUMBER
xml
<Action type="SET_NUMBER">
<Copy source="PRICE" precision="2" round="UP" />
</Action>1
2
3
2
3
| XPath | Description | Occurs |
|---|---|---|
@source | The key of a Field with type NUMBER | 1 |
@precision | Decimal places | 1 |
@round | Round method, you can choose between: UP, DOWN, CEILING and FLOOR, HALF_UP, HALF_DOWN. You can read more about each option here | 1 |
Value of NUMBER
xml
<Action type="SET_NUMBER">
<Value>12.3</Value>
</Action>1
2
3
2
3
You can use this to set a default value.
Template on NUMBER
For numbers it allows to do calculations.
xml
<Action type="SET_NUMBER">
<Template precision="0" round="CEILING" engine="twig.1">
<![CDATA[
{{source("WIDTH_MM")}} / 10
]]>
</Template>
</Action>1
2
3
4
5
6
7
2
3
4
5
6
7
You can use:
*for the multiplication/for the division+for the addition-for the substraction- You can also use parentheses
Apply a suffix
To apply a suffix you have to specify within the Action the field NUMBER, that unit.
xml
<Action type="SET_NUMBER">
<Copy source="PRICE" precision="2" round="UP" suffix="EURO"/>
</Action>1
2
3
2
3
SINGLE-SELECT actions
Then the Action/@type must be SET_OPTION. Then you can use these actions:
Map a SINGLE-SELECT
xml
<Action type="SET_OPTION">
<Map source="MAIN_COLOR">
<Entry source="RED" target="RED" />
<Entry source="BURGUNDY" target="RED" />
<Entry source="MAGENTA" target="RED" />
<Entry source="BLUE" target="BLUE" />
<Entry source="AZURE" target="BLUE" />
<Entry source="PETROL" target="BLUE" />
<Entry source="GREEN" target="GREEN" skip="true" />
<Entry source="YELLOW" skip="true" />
</Map>
</Action>1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
| XPath | Description | Occurs |
|---|---|---|
@source | The key of a Field with type SINGLE-SELECT or the key of a Classification | 1 |
Entry | For each Option | 1..* |
Entry/@source | The key of the source option | 1 |
Entry/@target | The key of the target option. If the attribute skip is set false, the target must be defined.If the attribute skip is set true, the target must not be set. | 0..1 |
Entry/@skip | Set true to skip this entry while processing the rules. It will be also marked as skipped in the UI. If an entry is ignored, no value is set. If false or absent, the property is not taken into account and is not exported. | 0..1 |
Value of SINGLE-SELECT
xml
<Action type="SET_OPTION">
<Value>RED</Value>
</Action>1
2
3
2
3
You can use this to set a default value. The value must be a valid Option key of the target Field.
MULTIPLE-SELECT, MULTIPLE-SELECT-QUANTIFIED et MULTIPLE-SELECT-QUANTIFIED-WITH-COMMENTS actions
Then the Action/@type must be SET_OPTIONS. Then you can use these actions:
Map a MULTIPLE-SELECT, MULTIPLE-SELECT-QUANTIFIED et MULTIPLE-SELECT-QUANTIFIED-WITH-COMMENTS
xml
<Action type="SET_OPTION">
<Map source="COLORS">
<Entry source="RED" target="RED" />
<Entry source="BURGUNDY" target="RED" />
<Entry source="MAGENTA" target="RED" />
<Entry source="BLUE" target="BLUE" />
<Entry source="AZURE" target="BLUE" />
<Entry source="PETROL" target="BLUE" />
<Entry source="GREEN" skip="true" />
<Entry source="YELLOW" target="YELLOW" skip="true" />
</Map>
</Action>1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
| XPath | Description | Occurs |
|---|---|---|
@source | The key of a Field with type SINGLE-SELECT or the key of a Classification | 1 |
Entry | For each Option | 1..* |
Entry/@source | The key of the source option | 1 |
Entry/@target | The key of the target option. If the attribute skip is not set to true, the target must be defined. | 0..1 |
Entry/@skip | Set true to skip this entry while processing the rules. It will be also marked as skipped in the UI. If an entry is ignored, no value is set. If false or absent, the property is not taken into account and is not exported. | 0..1 |
Value of MULTIPLE-SELECT, MULTIPLE-SELECT-QUANTIFIED et MULTIPLE-SELECT-QUANTIFIED-WITH-COMMENTS
xml
<Action type="SET_OPTIONS">
<Value>RED</Value>
<Value>BLUE</Value>
</Action>1
2
3
4
2
3
4
You can use this to set a default value. The value must be a valid Option key of the target Field.
For Fields with type MULTIPLE-SELECT-QUANTIFIED you can set:
xml
<Value quantity="2">HDMI</Value>1
For Fields with type MULTIPLE-SELECT-QUANTIFIED-WITH-COMMENTS you can set:
xml
<Value quantity="2" comment="1 hdmi 3.1 and 1 hdmi 2.0">HDMI</Value>1
CLASSIFICATION actions
Then the Action/@type must be SET_OPTION. Then you can use these actions:
Map a CLASSIFICATION
xml
<Action type="SET_CATEGORY">
<Map source="TYPOLOGY">
<Entry source="laveVaisselle" target="DISHWASHER" />
<Entry source="frigo" target="FRIDGE" />
<Entry source="réfrigérateur" target="FRIDGE" />
<Entry source="congélateur" target="FREEZER" skip="true" />
<Entry source="four" skip="true" />
</Map>
</Action>1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
| XPath | Description | Occurs |
|---|---|---|
@source | The key of a Field with type SINGLE-SELECT or the key of a Classification | 1 |
Entry | For each Option | 1..* |
Entry/@source | The key of the source option/category | 1 |
Entry/@target | The key of the target category. If the attribute skip is not set to true, the target must be defined. | 0..1 |
Entry/@skip | Set true to skip this entry while processing the rules. It will be also marked as skipped in the UI. If an entry is ignored, no value is set. If false or absent, the property is not taken into account and is not exported. | 0..1 |
Value of CLASSIFICATION
xml
<Action type="SET_CATEGORY">
<Value>FRIDGE</Value>
</Action>1
2
3
2
3
You can use this to set a default value. The value must be a valid Category key of the target Classification.
IMAGE actions
Then the Action/@type must be SET_IMAGE. Then you can use these actions:
Copy IMAGE
xml
<Action type="SET_IMAGE">
<Copy source="FRONT_VIEW" width-px="1000" height-px="1000" quality="90" format="jpg" />
</Action>1
2
3
2
3
| XPath | Description | Occurs |
|---|---|---|
@source | The key of a Field with type IMAGE | 1 |
width-px | Optional to resize the width of the image | 0..1 |
height-px | Optional to resize the height of the image | 0..1 |
quality | Optional to change the quality and size of the file. A number from 1 to 100. | 0..1 |
format | Optional to force the format of the image to jpg or png | 0..1 |
ATTACHMENT actions
Then the Action/@type must be SET_ATTACHMENT. Then you can use these actions:
Copy ATTACHMENT
xml
<Action type="SET_ATTACHMENT">
<Copy source="INSTRUCTIONS" />
</Action>1
2
3
2
3
| XPath | Description | Occurs |
|---|---|---|
@source | The key of a Field with type ATTACHMENT | 1 |
Outputs
| Property | Type | Description |
|---|---|---|
YES the whole file went in, NO at least one entry of the file was refused. See Execution report. | ||
| A report file of warnings and errors. |
Execution report
The report output is an XML file whose structure is described in the reporting tutorial. Each rejection below appears there as one <Log type="error"> entry carrying its code in a <Metadata name="code"> element. This task never produces an info or a warning log: every entry in its report is an error.
allRulesImported is YES when the report holds no rejection at all.
Rules life cycle
The file is interpreted as an exhaustive file.
Warning!
Therefore rules that are in the file are updated or created, and rules that are not in the file are removed.
Limits and additional notes
These limits apply to one mapping - the rules of a single target table, for your account.
| Element | Limit |
|---|---|
| Fields with rules | 20 000 |
| Rules by field | 1 000 |
| Source tables | 500 |
| Rules by table | 20 000 |