Script wizards

Wizard types

Script wizards are simplified interfaces for common scripts in templates. These are the available Script wizard types.

  • Text Script: This is the default script that is created when a data field is dragged from the Data Model onto the page. See Variable Data.
  • Dynamic Image Script: Provided that its selector refers to an image, this script dynamically changes the image for each record. See Dynamic images.
  • Dynamic Background Script: This type of script dynamically swaps a Print section's background. See Dynamic Print section backgrounds.
  • Email Scripts. The Email To Script is automatically added to any new Email context; it defines where the email should be sent for each record. Other Email scripts define other recipients, the subject of the email that is sent, and the PDF password. See Email header settings.
  • Barcode Script: This script controls the contents of a Barcode. It is automatically added when a barcode is added to a template. See Barcode
  • Business Graphic Script: This script controls the contents of a Pie Chart, Bar Chart or Line Chart. See Business graphics.
  • Conditional script: This script shows or hides content elements depending on certain conditions and values. See Showing content conditionally.

The result of the script can be either text appearing on the page, an email address or subject, the barcode data, or a JSON string that is written to the attribute of an HTML element.

Options

For the options in Conditional Script wizards see Conditional Content script dialog.

In other Script wizards, the following options are available.

  • Name: The name of the script, making it easier to identify it.
  • Selector/Find text: The Selector or Text to apply the result of the script to.
    • Selector: Uses CSS selectors to find the element to which the script applies
    • Text: Uses text as a trigger for the script. The script applies to all instances of the text found in the template.
    • Selector and Text: Uses text as a trigger for the script but only applies to text within the specified Selector.

    Email script wizards don't have the Selector or Find text option. Instead they select the header of the specified Section (the current one, by default) or All email sections. Note that the Section name is case-sensitive.

    To see the actual (HTML) selector that an email script uses to select a section, you can click the Expand button.

  • Wizard Results: Displays a list of the data that replaces the content that matches the script's selector:
    • Prefix: Static text to use before the set field. For example in Dynamic Image scripts, the default prefix is images/.
    • Field: A drop-down to select which field contents to use in the script. The field should contain a valid value. For an email script, for example, the field would have to contain an email address. Note that you can't select a field that belongs to a detail table.
    • Format: A special formatting modifier applied to the Field; see Formatting variable data.
    • Suffix: Static text to use after the set field. For Dynamic Image Scripts, the default suffix is .jpgand refers to the file extension.
  • [+]: Adds a new line to the Wizard Results. Note that by default there is no line return between fields in the list. Adding <br> in the Suffix or Prefix field can establish a line return.
  • [-]: Removes the currently selected line in the Wizard Results list.
  • Arrow Up: Moves the currently selected line up one position.
  • Arrow Down: Moves the currently selected line down one position.
  • Refresh Types: Updates field types to match the types in the active data model.
  • Options (only available in the Text Script wizard and the Dynamic Image wizard): specifies where and how the script inserts its results:
    • As HTML. HTML elements in the results are processed and displayed as HTML elements. For instance, <b>this is bold</b> will be displayed as this is bold. This is the default setting.
    • As text. This inserts the results as-is, meaning HTML tags and elements are displayed as text in the output. In this scenario, "<br>" shows up in the text and does not insert a line break.
    • As the value of an attribute of an HTML element. The selector of the script should be an HTML element. Which attributes are available depends on the selected HTML element. If the script's selector is an image (<img> element) for example, and the attribute is src, the script will modify the image's source. The script's results should be a valid value for the chosen attribute.
    • When checked, the option Convert fields to JSON string writes the results from the script into an attribute or text as a JSON string. This is useful for Web contexts where a front-end script can read this value easily.
  • OK: Click to save any changes made to the script, apply the changes in the template, and close the dialog.
  • Cancel: Click to close the dialog without saving changes.
  • Expand: Click to convert the script generator to a regular script. Note that this action is not reversible once the regular script has been saved. The expanded script will use either double or single quotation marks, depending on the Preferences (Window > Preferences > Scripting; see Scripting preferences).
  • Apply: Saves changes made to the script and applies the changes in the template without closing the dialog.

Expanded Script window

When expanded, the Script window replaces all parts of the wizard below the Selector by a box in which the script can be typed. See Writing your own scripts.

For an overview of keyboard shurtcuts that can be used in this script editor, see Keyboard shortcuts.