1.6

Table Of Contents
Tip
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.
Tip
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).
Setting boundaries using JavaScript
As soon as you select the On Script option as the trigger for establishing record boundaries,
you are instructing the DataMapper to read the file sequentially and to trigger an event each
and every time it hits a delimiter. In other words, the script that you'll be writing will be executed
- by default - as many times as there are delimiters in your input data.
If you know, for instance, that your PDF file only contains documents that are 3-pages, your
script could keep count of the number of times it's been called since the last boundary was set
(i.e. the count of delimiters it encountered) and each time the count is a multiple of 3, it could set
a new record boundary. You would basically have recreated the same functionality that is
Page 220