Using scriptlets in script tasks

Use a scriptlet instead of JavaScript to generate a large amount of text, with variable parts that are computed by using embedded JavaScript. Unlike the general script, a scriptlet can produce a value only for a single variable.

About this task

The purpose of a server-side script is to do computations in JavaScript, and assign values to one or more service flow variables. However, when the required values are strings that consist of several lines (such as HTML, XML, or SQL snippets), generating them by using JavaScript can be clumsy to write and read. Here scriptlets can be used as an alternative. Scriptlets are available in service flows.

Procedure

  1. Specify the binding with a variable of the service flow, to which the computed result will be assigned.
    The variable is usually of type String. If it is not of type String, it should be a basic type (such as Integer, Decimal, Boolean, or XMLElement, from the System Data toolkit); then the string that is the result of the text with embedded JavaScript is converted to the required type before the assignment.
  2. Specify the text that contains embedded JavaScript, as described in Syntax for text with embedded JavaScript. This is the text with JavaScript computations that produces the resulting string.

Results

The text including generated elements is assigned to the variable of the service flow.