1.6

Table Of Contents
Warning
When you change an expanded text script and save it, it becomes impossible to
edit the script using the Script Wizard again.
2.
Write the script. Click Apply from time to time to see if the script works as expected. This
will be visible on the Preview tab in the main workspace.
Syntax rules
Every script in the Designer 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: http://www.w3schools.com/js/js_
syntax.asp and http://www.w3schools.com/js/js_if_else.asp.
Tip
In the editor window, press Ctrl+Space to see the available features and their
descriptions.
Use the arrow keys to select a function or object and press enter to insert it in the
script.
Type a dot after the name of the function or object and press Ctrl+Space again to
see which features are subsequently available.
Two basic code examples
Writing a script generally comes down to modifying the piece(s) of content collected from
the template with the script's selector, using values, or depending on values of the record
that is being merged to the template at the moment the script runs.
Modifying the template
To access and change the results of the query that is carried out with the selector (in other
words: to modify the output), use the object results.
The following script (with the selector p) changes the text-color of all paragraphs to red
with a single line of code:
results.css('color', 'red')
Page 531