2020.2

Table Of Contents
Examples
This script looks up an image in an element with the ID #calloutbox and sets its alternative text
to a value from a data field.
var altText = record.fields.FavHobby;
query("#callout img").attr('alt', altText);
The following script sets the background color of a specific table cell in an email to red if the
value of the field TOTAL has a negative value in the current record.
if(record.fields.TOTAL<0) {
query("#total").attr("bgcolor","red");
}
before()
Inserts content before one or more HTML elements, which can be:
l The elements that match the selector of a script (see "results" on page1420).
l One element that matches the selector of a script that runs for "Each matched element"
(see "this" on page1338 and "Setting the scope of a script" on page860).
l The elements returned by a query in the template (see "query()" on page1293).
See also: "after()" on page1345.
before(content)
Before(content) inserts content before one or more HTML elements and creates a new result
set.
content
String, HTML string or result set to insert after the elements. In case a plain text string is
provided, it is automatically wrapped in a <span> element to avoid orphan text nodes to
appear in the <body> element.
Examples
This script looks for an element with the ID salesrepand inserts a paragraph before that
element.
Page 1310