Write Your Own Scripts

Data mapping can be taken a lot further than just performing basic extractions. Every part of your extraction process can be customized using scripts. This topic explains how scripts work and how you can create and write a script.

How Scripts Work

A script is a small set of instructions, written in JavaScript. When Connect generates the actual extraction process, it takes each step, one by one, and runs all scripts for it.

Creating a New Script

In DataMapper, you can use scripts to set Boundaries (see Boundaries Using JavaScript) or in the Step Properties for steps such as:

  • Extraction step where the data selection is based on JavaScript or you can enter a post function script.
  • Action step using the set properties based on JavaScript or you can use JavaScript run script.
  • Condition step where the left and right operands are based on JavaScript.

See Step Properties for more information.

From the Settings or from the Step Properties pane, click the Use JavaScript Editor button. The Edit script dialog appears:

In the Edit script dialog, press Ctrl-Space to bring up the list of available JavaScript objects and functions (see Datamapper API). Use the arrow keys to select a function or object and press enter to insert it. Type a dot after the name of the function or object to see which features are subsequently available.

Syntax Rules

Every script in the DataMapper must follow JavaScript syntax rules. For example, each statement should end with ; and the keywords that can be used, such as var to declare a variable, are JavaScript keywords. There are countless tutorials available on the Internet to familiarize yourself with the JavaScript syntax. For a simple script all that you need to know can be found on the following web pages: https://developer.mozilla.org/en-US/docs/Web/JavaScript.

For more examples of using conditions, see this how-to: Combining record-based conditions.

DataMapper API

Certain features do not exist in the native JavaScript library. These are additional JavaScript features, designed for use in Connect only. All features designed for use in the DataMapper are listed in the DataMapper's API (see DataMapper API).

 
  • Last Topic Update: 24/01/2017 09:32
  • Last Published: 7/6/2017 : 9:48 AM