JavaScript expressions in business objects, event objects, and action objects

You can use JavaScript expressions in Decision Server Events to perform various data manipulation functions, including string manipulation, mathematical calculations and array processing. JavaScript expressions can be used in business objects, event objects (in event field constructors) and action objects. The result is a value that is evaluated by the event runtime during event rule evaluation (for events and business objects) or passed to a touchpoint system (for actions).

You can declare variables and assign values to those variables. All variables are considered local to the business object, event object field constructor or action object where they are defined.
Restriction: Although the full range of JavaScript syntax is supported, only data manipulation activities make any sense in Decision Server Events. You must not include JavaScript commands used to display data (for example, alert). Also, no formal syntax checking is performed, so you must ensure that JavaScript syntax is correctly constructed. See, Testing JavaScript in Event Designer.

Colors displayed in JavaScript expressions

When you enter a JavaScript expression, different colors can be displayed in the JavaScript expression box. Table 1 summarizes what each of the colors represents.
Table 1. JavaScript expression colors
Color What the color indicates
Green Comments in the expression.
Blue Character literals and string literals (including escape sequences).
Purple A reference to a single instance of the field.
Bold purple The field reference is to every instance of a field in an array of objects.
Red JavaScript keywords.
Black All other elements in the JavaScript expression.

JavaScript content assist

When you want to enter a JavaScript expression in a business object, event object (in event field constructors), or in an action object, you can use the content assist menu. To open the content assist menu, in the JavaScript expression box, press Ctrl+Spacebar. Then, double-click an entry in the available list to add the entry to your JavaScript expression. You can continue to use the content assist menus to complete your JavaScript expression.

JavaScript content assist example

An example of a JavaScript content assist menu is shown in the following screen capture:

JavaScript content assist example

For more JavaScript examples, see Examples of JavaScript in Event Designer