Designer Scripts API

This page lists the global objects and functions that are available in scripts, created inside the Scripts pane. Click through to an object or function to get a description and examples.

If you are not familiar with writing scripts, see Writing your own scripts.

Control Scripts

Control Scripts are a special kind of Designer Scripts. They don't touch the content of the sections themselves, but they change the way a template is outputted, for example by selecting or omitting sections from the output. For more information about Control Scripts and their use, see Control Scripts. Features that are specific to Control Scripts are listed in the Control Script API.

Objects

Object Description
results This object is used to manipulate the content of the template. It contains the HTML element or set of HTML elements that match the selector of the script, specified in the script editor.
This object is not available in Control Scripts, because that type of script doesn't have a selector (see Control Scripts).
record The record in the main data set that is currently being merged. To get the value of a field in the record, use record.fields['fieldname'] or record.fields.fieldname.
logger Global object that allows you to log messages.
locale Defines which locale to use. See Locale.
formatter Global object that allows you to format values (such as a date or number).
automation This object encapsulates the properties of the Workflow process that triggered the current operation. Not available in PrintShopMail Connect.
merge The merge object is mainly used in Control Scripts. It gives access to the template with all of its contexts and sections. It doesn't give access to the content of the sections. To change the content of a section, you would create a script with a selector and use the results object in the script (see results).

Global functions

Function Description
loadhtml() ​Loads HTML data from a HTML (snippet). The returned HTML can be placed into a variable or into a set of HTML elements.
loadjson()​​ ​Loads json data from a URL. This is a simple way to retrieve content from external systems.
​​query() ​Performs a query in the template's contents and creates a new result set containing the HTML elements that match the given CSS selector.

Examples of iterator functions

Function Description

Each

A generic iterator function, to iterate over the elements in the result set

For...in​​​ ​Iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.
 
  • Last Topic Update: 07:59 AM Dec-20-2016
  • Last Published: 2019-05-22 : 2:52 PM