Page cover

Advanced Scripting

Rule types

These are the types of rules in the application and they are run in this order:

Order
Rule Type
Description

1

Import Rules

Processes data coming from a data source

2

Comparison Rules

Processes data that has already been processed by import rules for both sources

3

Display Rules

Displays warning or error rectangles (orange or red) based on the outcome of a rule

4

Export Rules

Changes data going to a data source

The basic rules (preset rules you choose from the list) all fall into categories 1,3,4.

Advanced Rules on the other hand fall into all the categories and are more difficult to use, but they are much more powerful than other (preset) rules.

Advanced rules may be reworded as User Scriptable Rules (JavaScript) and have access to 4 parameters, instead of being limited to the provided parameters. The rules that fall into this category are:

  • Text Manipulation (import / export)

  • Text Evaluation (display)

  • Export Manipulation (export only)

  • Comparison (uncheck process checkbox)

Parameters of a rule

The parameters available to these rules are listed below:

Parameter
Description
Note

s

The current string value from the source

Can be modified by previous rule

rowData

The entire row's data (all the cell values, modifications, differences, etc.)

Cannot be modified, read-only

p

The pass / block value

Cannot be modified, read-only

pm

The property mapping object

Contains additional options such as "Is it read-only"

Typical rules only manipulate or use the string value s which is passed to it. The table above lists the data to which special rules have access to. It allows for much greater scripting capability.

The resultant message is displayed onscreen during a rule evaluation failure

Should you happen to break your BOM view using these custom scripts, simply disable the rule or delete them to restore the BOM view. Click the 'Undo Changes' button for rules to re-evaluate on the existing BOM.

Param
Description

s

The current string value in the cell (changes with each successive import rule or export rule (if there are any)

rowData

The rowData object (more detail below **)

p

The pass / block value, does not change

pm

The Property Mapping's object. Does not change. (** more detail below)

s Parameter

The s parameter is the representation of the cell value. Most of the time this is a value of type string but sometimes it can be a type JSON object or a JSON array (if using say an import manipulation rule to change the type).

It is important to note that the sparameter is a per-source value. It is not shared between sources.

Below is a graphic representing how the value is treated and displayed onscreen

If you see a value onscreen shown as [object Object] this means you have a JSON object or array that needs to be parsed or converted into a different type

rowData Parameter

The rowData is the row itself including any cells, differences or modifications. It contains, but is not limited to, the following key/values:

Key name
Description of the value

isAssemblyRow

A bool value indicating if the current row value is an assembly row (contains children according to the source)

componentName

The primary identifier of each row - typically the name of the component

componentPathArray

The path of each component. So if you have assembly A1, with Part P1, then this value will be [ 'A1', 'P1' ]

cells

The row values for the entire row. The .cells object always stores the values from the primary source only. The differences stores any values from the Secondary that's different. A typical row object might look something like this (notice the nested `cells` key):

modifications

All changes made for cells in the row. This can occur when the user enters new text, makes a different selection, or the secondary value is preferred (Prefer {SecondaryDataSource } Value checkbox in the property mapping settings)

differences

When the data is loaded from the Primary + Secondary DataSource, this contains the differences between each cell. Anything that is different is listed in this object.

primarySourceExportData

object containing the final set of data to send to the Primary Source. This is the final set of values to be sent.

secondarySourceExportData

object containing the final set of data to send to the Secondary Source. This is the final set of values to be sent

p Parameter

The p parameter is the PassOrBlockvalue specified in the Property Mapping Rule options. You cannot affect this with javascript, but you may read the value.

pm Parameter

The pm value contains values related to the Property Mapping used for this column. It cannot be modified, and any modifications to it are ignored. It contains, but is not limited to, the following key/values:

Key name
Description of the value

isReadOnly

Whether the admin has selected this property as editable

isVisible

Whether the admin has selected this property as visible by default

shouldUpdatePrimaryDatasource

Whether to update the Primary Source

shouldUpdateSecondaryDatasource

Whether to update the Secondary Source

Last updated