Rules engine
What is the rules engine?
The rules engine allows to automate data entry on tables shared by partners.
Why?
Your partners ask you to complete many attributes, however you usually already have this information in your systems, so what you need is to automate data entry.
By connecting Product-Live to your systems, or using Product-Live as your main data source, you can then map your attributes to those of your partners, so you don't have to re-enter information when possible.
Therefore the rules engine is mainly used by suppliers and vendors.
How to prioritize
Please consult the following document for best practices Mapping Methodology (French version).
How to activate the rules engine?
Info
Usually this step has been done by Product-Live. If you already have mapped columns, skip this section and go to the next one How to map columns?.
Every users that have access to a shared table. Rules engine must be activated by shared table.
To do so, first select your partner here:
Then click on the settings icon next to the table name and click on Link tables:
Here you define which table must used as a source, and which column must be used as pivot to find the "same" item.
Info
Only columns with the type Identifier can be used here.
Best practice
For products data you must use the EAN as a pivot.
How to map columns?
Go to the column that you want to automate and click here:
This will open a panel on the right where you will configure the action and the conditions:
Action
The action depends on the data type of the column (text, number, image, select...).
In this example we are automating the data entry of a text column, so here we can:
- Use a value from another field
- Use a default value
- Concat fields
We will see more examples later in this tutorial.
Only if
You can define in which conditions the action can be executed.
This also allows to create multiple rules on the same column, but we will see later in the tutorial some practical examples.
That's it!
When a column is mapped you can view this symbol:
Now you can read more about each actions and how to use the conditions.
What kind of actions can be done?
It depends of the data type of the target column.
When the target column is a Text
Actions available
- Use a value from another field
- Use a default value
- Concat fields
Columns that can be used as source
You can only use source with data types:
- Identifier
- Single line text
- Long text
- HTML text
- Number, the dot will be used as a separator and cannot be customized
- Single select, then you must choose between using the
key
or theTitle
or theTitle-Local
of the option - Multiple select, then you must choose between using the
key
or theTitle
or theTitle-Local
of the option, the final value will be joined by;
- Multiple select, then you must choose between using the
key
or theTitle
or theTitle-Local
of the option, the final value will be joined by;
with the template[quantity] :[value]
- Multiple select with comments, then you must choose between using the
key
or theTitle
or theTitle-Local
of the option, the final value will be joined by;
with the template[quantity] :[value],[comment]
- Classification, then you must choose between using the
key
or theTitle
or theTitle-Local
of the category - Image, the public url of the file will be used
About concatenation
Use {
to reference an attribute. source() is used to reference an attribute in a source table and target() to reference an attribute in the target table. You can use HTML tags for formatting if the target attribute allows it.
If you are using Fields with types Single select or Multiple select then you must select a second parameter to define which value must be used, you can select between:
- key is the technical code of the option
- title is the title of the option that you can see in the application
And then the third parameter allows to select a language if you have configured your source structure as multilingual.
To keep it simple, first always select title
for the second parameter and default
for the third parameter.
When the target column is a Number
Actions available
- Use value from another field
- Use a default value
- Use a formula
Best practice
If your retailer ask you the width of the product in cm and you have it within your system in mm, then use the formula to divide your value by ten.
Columns that can be used as source
You can only use source with data type:
- Number
If you need to use a Text column as source then see the advanced tutorial Map a Text column to a Number column.
About units
When the target column is a Number with units, you can set the unit to be applied with the value. A single unit can be set per rule. If you have to automate a number with distinct units, either use conditions on the unit, or create multiple rules: one for each target unit.
About formulas
Use { to reference an attribute. source() is used to reference an attribute in a source table and target() to reference an attribute in the target table. You can use HTML tags for formatting if the target attribute allows it.
You can use:
*
for the multiplication/
for the division+
for the addition-
for the substraction- You can also use parentheses
About rounding methods
More information about the rounding methods can be found here.
When the target column is a Single or Multiple Select
Actions available
- Use value from another field, and you will be able to map each options
- Use a default value
Columns that can be used as source
You can only use source with data type:
- Single select
- Multiple select (with quantity and with comment)
- Classification
Archived options and categories are displayed by default so that you can check if one of them has to be updated. You can hide them to focus on only relevant values.
If you need to use a Text or Number column as source then see the advanced tutorial Map a Text or Number source column to a Select or Classification column.
When the target column is a Classification
Actions available
- Use value from another field, and you will be able to map each categories
- Use a default value
Columns that can be used as source
You can only use source with data type:
- Single select
- Multiple select (with quantity and with comment)
- Classification
Archived options and categories are displayed by default so that you can check if one of them has to be updated. You can hide them to focus on only relevant values.
If you need to use a Text or Number column as source then see the advanced tutorial Map a Text or Number source column to a Select or Classification column.
When the target column is an Image
Actions available
- Use value from another field
Columns that can be used as source
You can only use source with data type:
- Image
Tip
You can transform the size of images with option Resize image
When the target column is an Attachment
Actions available
- Use value from another field
Columns that can be used as source
You can only use source with data type:
- Attachment
When the target column is a Date or a Date time
Actions available
- Use value from another field
Columns that can be used as source
You can only use source with data type:
- Date
- Date time
How to use conditions?
In the examples below there is one retailer named RetailerX that share a table with a supplier named BrandX like this:
The target Products table of the retailer contains two fields :
- EAN the EAN 13 of the product
- Label the label displayed in the website
The source Products table of the supplier contains also two fields:
- EAN 13 the EAN 13 of the product
- Title the title of the product
BrandX has configured the rules engine like this:
- EAN 13 is mapped with EAN and is used to link tables
- Title is mapped with Label
Now we will see how to use the conditions.
No conditions
If there is no conditions, then if there is a value in the source table then it will update the target table. Then you will have:
But if the source value is empty, then it will erase the target value:
Important
Be aware that if you do not set conditions, values in the target will be erased if the source value is empty.
This is also true if you have updated the target field manually.
Do not erase if the source is empty
If you do not want to erase the target value when the source value is empty, then you must add this condition:
Then if the source value is empty, after the execution you will have this result:
As you can see the target value is not altered.
Do not erase if there is already a value in the target
If you need to initialize the target value and then update it manually, then you can set a condition on target:
Then it will give this result:
As you can see conditions can be used to define which behavior you want to apply. There is no global rules, it really depends on your needs.
If you do not set conditions, then it will mirror your data source.
Automate measures with their unit
If you need to automate a target field based on number field unit, you need to create a rule for each unit by setting a condition on the SUFFIX
.
Advanced mappings
Map a Text column to a Number column
Warning
It is not a best practice to store numbers as text, it can leads to a lot of critical business errors.
What is the problem?
- To be filtrable and sortable a number must be stored as a number, otherwise you cannot sort numbers from highest to lowest or filter by range.
- If the source data is a text then it can be anything, therefore the conversion of the value from text to number is not predictable.
For example, 1,000.90 in US is equivalent to 1 000,90 in Europe, but 1,000 in US is not equivalent to 1,000 in Europe. Moreover some old systems store a NA
value or -
value when there is no value.
Data source that store numbers as text are old software that limit your business and you should consider upgrading them.
What is the solution?
The best solution is to update your data source from a Text column to Number column. If your source system cannot do that it's time to use Product-Live as your main data source. Our customer success teams can help you to refine your source data structure with best practices. You can contact our customer success team here: contact the customer success team.
If you cannot change your data source, then you can use the conditions to create one rule for each text input. To do so, in Action select Use a default value and set a value. Then in Conditions setup the conditions when this value must be used.
You will have a setup like this:
Before saving click on add new rule:
You will be asked to enter a rule name, you can use the pattern: Name of the attribute for value
Click on Save and add a new rule. This will immediately open the same form. Fill the form with another value and conditions and click on Save. Then you will see your two rules like this:
Here you can change the execution order or create new rules.
Best practice
If you have a few predictable text inputs, then you can use conditions, but if the values are not predictable then there is no other solution to transform your data source to a Number column.
Map a Text or Number source column to a Select or Classification column
Requirements
You have read the previous example, if not click here.
This is the same case as before. The problem is that Text or Number values cannot be predictable (imagine a Text value Green, which can also be written: green, GREEN, 104 = the color code...), therefore the bypass is to create a rule for each input value.
Best practice
As before you should consider using the right source input data type in your systems. If your systems cannot do that it's time to use Product-Live as your main data source. You can contact our customer success team here: contact the customer success team.
Map a Classification column depending on multiple source columns
In this example the start configuration is like below:
The target Products table of the retailer contains two fields :
- EAN the EAN 13 of the product
- Classification the classification used on the website, it can take two values:
- Vacuum cleaner wireless
- Vacuum cleaner with wire
The source Products table of the supplier contains these fields:
- EAN 13 the EAN 13 of the product
- Typology the typology of the product, it can take two values:
- Vacuum cleaner
- Coffee machine
- Type is a field specific to the category Vacuum cleaner and can take two values:
- Wireless
- With wire
What BrandX wants to express is:
In my Products table, if typology is vacuum cleaner and type is wireless then it must the classification must be set to vacuum cleaner wireless on RetailerX, else if typology is vacuum cleaner and type is with wire then it must the classification must be set to vacuum cleaner with wire on RetailerX.
For this like in the examples above we will create multiple rules on the same field.
First create a rule for the first case like this:
- In action click on Use a default value
- Select the value
- In Only if add a condition on the Typology field
- Then add a condition on the Type field
- Then click on + Add new rule and create the second rule and giv this name:
Then click on Save and add a new rule button and create this configuration:
Finally you should have this configuration:
Application of rules
The application of the rules for shared table from partners is asynchronous, which means that an administrator must configure the periodicity of the execution of the rules. Usually Product-Live team has configured a periodic execution done during the night. If you want to learn more contact Product-Live support.
You can also select a list of items and directly applying the rules, but for this your administrator must have configured an action. If you want to learn more contact Product-Live support.
FAQ
Can I use the rules engine on my own table?
For the moment the rules engine must only be used to automate data entry on tables shared by partner. It is planned to have the same rules engine but for your data, and the execution of the rules will be synchronous, which means that when you will edit a cell, the application will be in real time (like the application of the conditional formatting rules). For example this will allow to:
- Calculate dimensions
- Auto generate texts from attributes
- Calculate all taxes included price from a price without tax column and a tax column
- Calculate status based on other fields
Can I use the rules engine to generate text from attributes on my table?
For the moment do not use rules engine for this, wait until the synchronous execution will be added. We will also add features for this particular need, like adding a feature "to not display an attribute if the value of the attribute is empty".