Rules
To configure the rules for each Property Mapping, click on the corresponding rules icon in the Rules column.
Rule Type or Category
Rules for property mappings fall into 1 of 3 categories:
Import Rules
Modifies incoming data
Data Transformation
Tooltip
Export Rules
Modifies outgoing data
Data Transformation
Tooltip
Display Rules
Validates data on-screen
Data Validation
Tooltip + Cell border
Order of Rules
Each type of rule can be reordered within it's own category, but you cannot move an export rule before an import rule The order that rules run in always follow the following order:
Import
Display
Export
You can reorder the rules (there are individual up/down buttons next to the header), but export
rules cannot appear before import
rules. Import/Export rules have an orange border, while display rules only have a gray border.
Display Rules (Data Validation) evaluates the data displayed on-screen after being retrieved from a Data Source and after all applicable Import rules have been processed.
Concept: Individual sources
Import rules work on the raw source data and are applied to each individual data source's data.
Each rule runs only on the source that it is being applied on (see image below)
Rule Legend
When a rule passes, the user is not informed of any problems with the data. When rule fails, a border is displayed on the cell where the problem appears.
Orange border - Value did not pass display mapping rule (Warning), the user is able to continue.
Red border - Value did not pass display mapping rule (Error), the user is not able to continue.
Configure Rules
Start by navigating to Property Mappings and click on "Rules" for the Property Mapping you want to edit.
A panel will appear on the side. Expand the Rules dropdown to reveal the available list of rules that can be applied.
Select the rule desired. Be sure to select the type of rule that best matches the data type. (Text, Numeric, JavaScript expression, Json value)
Select display, import or export to determine when the rule is applied:
Display applies the rule in the SharpSync BOM.
Import applies the rule as data is being imported into the SharpSync BOM.
Export applies the rule as data is being exported from the SharpSync BOM.
Click on Add Rule to show the rule in the list.
This icon tells you what type of rule it is:
Data Validation - Evaluates validity of the cell data.
Data Transformation - Changes cell data to match the rule type.
This header shows the rule action, and the arrows allow you to move the rule up or down the list.
Rules are evaluated from top to bottom. If you want one rule to execute before another, ensure it is ordered correctly.
Saves any changes you make to the rule.
Deletes the rule from the list.
Rule criteria
A textbox may be present to allow the user to define the rule parameter.
A description will be present if the parameter is not required.
On Rule Failure Action - Warning(s) will be present in the cell overlay when the rule fails.
Select pass to allow the user to still process the BOM.
Select block to require the user to fix the cell data before processing the BOM.
Depending on the rule selected, the bottom line may display options for processing the rule. Select the Data Sources that will be updated.
Closes and saves the Rules module. Rules in the list will be saved and applied to the BOM.
Notes
The final result for both rules are overlaid in the user interface (the default would be a blue rectangle). Below is a conceptual illustration of the process where
Data Source 1 is DS1
Data Source 2 is DS2
The rule running for DS1 (e.g. Onshape) is not aware of the data being imported from DS2 (e.g. NetSuite). That means that when running a rule such as a JavaScript Text Manipulation
rule, the function runs only for one source at a time, never for both at the same time.
Example
Let's suppose that we have Data Source 1 (DS1) and Data Source 2 (DS2), the process would be:
Step: Setup the property mappings
Setup the 1st column. Give it an accessor of
description
with a column mapping of propertydescription
for DS1 and for DS2
Setup a 2nd property column
description2
column. Give it an accessor ofdescription2
. Also map it to thedescription
property.Add a
Text evaluation
display rule to the 2nd column.
Step: Pulling the BOM + reviewing the data
For now let's say the value that comes from DS1 is the value
Coil
.Enable the setting on the 2nd column:
Prefer {DS2} Value
. This forces the value from DS2 to display instead of the value of DS1 displaying by defaultAdd a
Text evaluation
rule. This rule has access to ans
parameter (the current string value). Use the the following logic:If the value of
s
is equal to thedescription
property, return a message to the user.
Written out in JavaScript it would look like this
Note that returning any value in the message
above can be customized by you.
The data from DS2 is imported after that of DS1. The rules start running for DS2.
Display Rules
Text evaluation
Evaluates the cell value given the JavaScript expression. Available parameters:
s (display value)
rowData (the record containing the accessors data and additional metadata)
Notes on rowData
: rowData is a object which contains the following noteworthy child items:
rowData.cells (each cell value without modification. This can include the altered values as set in import rules)
rowData.modifications (any modifications made by the user as at the time the rule is run)
Special notes:
Whenever you create a text evaluation rule that evaluates the value of another cell, you must take into consideration the modifications of the other cell.
e.g. if the accessor you're evaluating for is myProperty1
and the condition is based on the value of accessor myProperty2
, first check in your rule for the existence of rowData.modifications.myProperty2
. If it exists, then use it, otherwise use rowData.cells.myProperty2
. Example below
Interpreting the Results
SharpSync processes and prioritizes each rule in order from top to bottom. Moving a rule up or down the list can change the result depending on the subsequent outcome. See the examples below to gain an idea of how results are evaluated:
Example 1: Text-based Rule Application
Preconditions
Property Mapping: Description (Text)
Sample Cell Data: "Connector Bracket 1_REL"
Rules
Prepend Text: "ABC-"
Text Must End with String: "_REL"
Maximum Text Length: 25
Evaluation
: Text is appended to be "ABC-Connector Bracket 1_REL"
: Text does end with the string "_REL"
: Text length is longer than maximum. Text was originally 23 characters; the prepended text makes the character length 27.
Quick Fix: change the text in SharpSync by removing characters or abbreviating words. Data Sources can be updated when the BOM is submitted with the changes, depending on the Property Mapping settings.
If the Maximum Text Length was ordered before the Prepend Text rule, all rules would evaluate as .
Example 2: Numeric Rule Application
Preconditions
Property Mapping: Weight (Numeric value)
Sample Cell Data: "123.54 kg"
Rules
Replace Text (removing spaces)
Orginal Value: " "
New Value: ""
Format as Decimal Number
Number of Decimals: 0
Remove Text: kg|KG|g|lb|lbs
Round to Nearest X: 1
Number Between
Min Value: 1
Max Value: 123
Evaluation
PASS: Space is removed, new text is "123.54kg"
PASS: Text is changed to Decimal. Any characters after tenth place is dropped. New value is 123.
PASS: Decimal is rounded to the nearest whole number of 123.
PASS: Number is between or equal to the minimum and maximum values of 1 and 123.
If the 2nd and 3rd rules were reversed, the last rule would fail. The number would be rounded first, which would result in the new number being 124, which is larger than the last rule's maximum value.
Last updated