Using Expressions with Variables

Advanced users who have knowledge of the JavaScript language can use expressions to perform string, mathematical, or other advanced operations on variables.

Syntax

The valid syntax to use is as follows: 

<%Expression%>

The expression that is enclosed by <% and %> is evaluated by the JavaScript engine. There must be no space characters just after the starting <% or just before the ending %>.

Examples of valid syntax are as follows:

Examples

You can use expressions in instances where a variable reference is used to read a variable's value. The following procedures give examples of where you can implement them in Integration Builder.

ClosedTo define the value of a custom global variable

  1. Click the Administration tab.

  2. Click Options.

  3. Under Custom Global Variables, click Add.

  4. In the Name field, enter a name for the custom variable.

  5. In the Value field, enter the JavaScript expression that you want. For example, enter the following expression:

    <%UserName.substr(0, UserName.lastIndexOf('\\'))%>

ClosedTo define the value of a custom integration variable

  1. Click the Create tab.

  2. In the Integrations pane of the Create view, click the integration that you want to create a custom variable for.

  3. In the integration components pane, click Variables.

  4. Under Custom Integration Variables, click Add.

  5. In the Name field, enter a name for the custom variable.

  6. In the Value field, enter the JavaScript expression that you want. For example, enter the following expression:

    <%UserName.substr(0, UserName.lastIndexOf('\\'))%>

ClosedTo specify a property in an integration

  1. Click the Create tab.

  2. Create the integration that you want. For example, create a Web Service integration.

  3. In the integration components pane of the Create view, click the component that you want. For example, click Service.

  4. In the Properties pane, click in the field that you want to add the JavaScript expression to. For example, under Web Service URL, click in the Service Name field.

  5. Enter the JavaScript expression that you want. For example, enter the following text and expression: 

    NextYear<%'Is' + (new Date().getFullYear() + 1)%>

ClosedTo specify the path of a document to print in a Print Document action

  1. Click the Create tab.

  2. In the Integrations pane of the Create view, click the integration that contains the Print Document action that you want.

  3. In the integration components pane, click the Print Document action.

  4. On the Document tab, click in the Document field.

  5. Enter the JavaScript expression that you want. For example, enter the following expression: 

    <%DetectedFilePath.substr(0, DetectedFilePath.lastIndexOf('.')) + ".btw"%>

ClosedTo set a variable's value in a Set Variable action

  1. Click the Create tab.

  2. Create an integration, and then add a Set Variable action to it.

  3. On the Set One Variable tab, under Variable, click in the Value field.

  4. Enter the JavaScript expression that you want. For example, enter the following expression: 

    <%DetectedFilePath.substr(0, DetectedFilePath.lastIndexOf('.')) + ".btw"%>

ClosedTo write a message that contains a variable expression in a Write Message to Log action

  1. Click the Create tab.

  2. Create an integration, and then add a Write Message to Log action to it.

  3. On the Write Message tab, under Message, click in the Variable field.

  4. Enter the JavaScript expression that you want. For example, enter the following text and expression: 

    File '<%DetectedFilePath.substr(0, DetectedFilePath.lastIndexOf('.')) + ".btw"%>' in %DetectedFileFolder% is being printed.

ClosedTo set an action's Action property to run the action conditionally

  1. Click the Create tab.

  2. In the Integrations pane of the Create view, click the integration that you want.

  3. In the integration components pane, click the action that you want.

  4. On the Action tab, click Conditionally, based on variable or Conditionally, based on expression.

  5. Click in the variable field that you want to add the JavaScript expression to.

  6. Enter the JavaScript expression that you want. For example, enter the following expression:

    <%new Date().getMonth() + 1)%>

ClosedTo specify which case action to run based on an expression evaluation result in a Select Case action

  1. Click the Create tab.

  2. Create an integration, and then add a Select Case action to it.

  3. On the Select Case tab, under Cases, click in the Select case using variable field.

  4. Enter the JavaScript expression that you want. For example, enter the following expression:

    <%Number(Variable1) + 0.1 + 0.2 + 55%>

ClosedTo iterate over start, end, or increment values that are specified by expressions in a For Loop action

  1. Click the Create tab.

  2. Create an integration, and then add a For Loop action to it.

  3. On the For Loop tab, under Options, click in the Name of iteration variable field.

  4. Enter the JavaScript expression that you want. For example, enter the following expression:

    <%RD_Documents.length - 1%>

Objects that can be used in expressions

Valid evaluation result types

All built-in JavaScript objects can be used in the expression, but not all of them are valid expression evaluation results. The following JavaScript types are accepted as valid: