SharpSync
  • Welcome
  • Fundamentals
    • Getting Started
      • Registration
      • Landing Page
      • Support
      • Subscription
    • Data Sources
    • Property Mappings
      • Adding Property Mapping
      • Property Mapping Settings
    • Rules
      • Import / Export
        • Append text
        • Calculate number
        • Export manipulation
        • Format as decimal number
        • Prepend text
        • Remove property
        • Replace all instances
        • Replace first instance
        • Round to nearest X
        • Select from JSON
        • Set cell value
        • Set empty cells
        • Text manipulation
      • Display
        • Number between
        • Text contains
        • Text ends with
        • Text evaluation
        • Text is a number
        • Text is exactly
        • Text is in list
        • Text is not a number
        • Text is not empty
        • Text is not in list
        • Text length between
        • Text length is exactly
        • Text maximum length
        • Text minimum length
        • Text not contains
        • Text not ends with
        • Text not starts with
        • Text starts with
      • Advanced Scripting
    • BOM Comparison
    • Data Safety
    • Troubleshooting
      • Duplicate component paths
      • OAuth 2.0
  • Data Sources
    • Autodesk Inventor
    • CSV
      • Getting Started
      • Importing a Bill of Materials (BOM)
    • MS Dynamics 365 Business Central
      • Getting Started
      • Item Fields Json & Internal Names
      • Resource Fields Json & Internal Names
      • List Names For nestedObject Mappings
    • NetSuite
      • OAuth Setup
        • Permissions
      • RESTlet Script Setup
        • SharpSync RESTlet Script
      • Thumbnail Folder Setup
      • Authentication + Configuration
      • Common setup
        • Configure quantity mapping
        • Configure accounts mappings
        • Configure itemType mapping
        • Configure isPhantom mapping
        • Configure subsidiary mapping
        • Configure price mapping
        • Configure Where Used Link mapping
        • Configure thumbnail mapping
        • Read-Only NetSuite Fields
        • Common Mapping Rules
        • Common List names
      • Advanced Bill of Materials
      • Configure Routings
      • Integration tips
      • Troubleshooting
    • Odoo
      • Getting Started
        • Authentication + Configuration
        • Debugging tips
      • Common Setup
        • Map BOM Codes
        • Map BOM Types
        • Map Attribute Values
          • Reading Attributes - Overview
          • Display All Attribute Names
          • Display Single Attribute Values
          • Writing attributes
      • Product Management
      • Hosting Options
      • List Names
      • Permissions
      • Troubleshooting
    • Onshape
      • Getting Started
      • Setting up Derivatives
    • Propel PLM
      • Getting Started
    • SolidWorks
    • SolidWorks PDM
      • Downloading and installing the add-in
      • Configure the add-in
      • Setting up the Solidworks PDM Web 2
      • Troubleshooting
      • Submitting a BOM for update
  • Advanced
    • Derivatives
  • User management
    • User Management
    • Application Permissions
Powered by GitBook
On this page
  • Parameters of a rule
  • s Parameter
  • rowData Parameter
  • p Parameter
  • pm Parameter
  1. Fundamentals
  2. Rules

Advanced Scripting

[Work in progress]

Advanced Rules are more difficult to use, but they are much more powerful than the other rules.

User scriptable rules (JavaScript) have access to 4 parameters, instead of just 1. The rules that fall into this category are:

  • Text Manipulation (import / export)

  • Text Evaluation (display)

  • Export Manipulation (export only)

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.

When the rule is an Import or Export Text Manipulation rule, the result of the rule must always be a string or a representation of a string such as a JavaScript object (JSON) which has been serialized. If it does not return a value you may experience unexpected results in the UI, possibly even instability (BOM view not rendering).

The result must be an object containing a 'message' key, e.g.

The resultant message is displayed onscreen during a rule evaluation failure

{ 'message' : 'if the rule fails show this text in the tooltip' }

Should you happen to break your BOM view using these custom scripts, simply disable the rules or delete them to restore the BOM view.

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. A typical row object might look something like this (notice the nested `cells` key):

modifications

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.

pm Parameter

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

PreviousText starts withNextBOM Comparison

Last updated 2 days ago

The pmvalue contains values related to the 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:

{
  "isAssemblyRow" : false,
  "componentName" : "Part 1",
  "componentPathArray" : [ "A1", "Part 1"],
  "cells" : {
     "partNumber" : "P1",
     "description" : "Side plate",
     "revision" : "A"
     "material" : "steel",
     "qty" : 1,
  }
} 
{
  "isAssemblyRow" : false,
  "componentName" : "Part 1",
  "componentPathArray" : [ "A1", "Part 1"],
  "modifications" : {
     "partNumber" : "P1-PN",
     "description" : "Side Plate",
     "material" : "Steel",
  }
} 
Property Mapping
Page cover image