|
Using scripts in the DataMapperIn the DataMapper every part of the extraction process can be customized using scripts. A script can be used to set boundaries for a data source (see Setting boundaries using JavaScript). The script determines where a new record starts. Scripts can also be used in different steps in the extraction workflow. You can:
The script can always be written directly in a small script area or in the Edit script dialog. To invoke this dialog click the Use JavaScript Editor button . 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.
Keyboard shortcuts for the script editor are listed in the following topic: Text editors: Source tab, JavaScript, CSS, Script Editor. Syntax rulesIn the DataMapper, all scripts must be written in JavaScript, following 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: http://www.w3schools.com/js/js_syntax.asp and http://www.w3schools.com/js/js_if_else.asp. A complete JavaScript guide for beginners can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript. DataMapper APICertain features that can be used in a DataMapper script 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 API (see DataMapper API). External JavaScript librariesThe External JS Libraries box on the Settings pane lets you add JavaScript libraries to your configuration and displays all the libraries that have been
imported (see Settings pane). Take the following JavaScript function, for example:
If this is saved as myFunction.js and imported, then the following would work anywhere in the configuration:
|
|