Defining Activity Inputs Using Expressions

Table of Contents

Specifying a Variable and a Hard-Coded Value

Specifying Java or JavaScript Code

Expressions are input values which typically consist of a variable and/or a hard-coded value (integer or non-integer). The variable can be an activity output, a workflow input or a workflow variable. Hard-coded values can also be Java objects.

Some activities may require expressions as their input values. Decision and Switch are some of the activities that use this type of input.

The following sections describe the steps to define activity inputs using expressions.

Specifying a Variable and a Hard-Coded Value

Consider the following example where the output of an activity is used as a variable to specify the input value of another activity:

You have a Workflow to check if specific clients in the CommCell are reachable. As part of the Workflow, you have a Decision activity which analyzes the results of the CheckReady activity and checks the client connectivity. To appropriately configure the Decision activity, you must specify the expression required by this activity, which will be based on the exit code output of the CheckReady activity:

  1. From the workflow design area, right-click the Decision activity and then click Properties.
  2. Click the Inputs tab and then click in the Value box.
  3. For the expression value, click Insert Variable, expand the CheckReady activity, and select exitCode. When added, it may look like this in the Value column:


  4. To make the expression represent the successful scenario of the CheckReady activity, exitCode must equal 0. Therefore, you must type == 0 next to the exit code variable in the Value column:

    xpath:{/workflow/CheckReady_2/exitCode} == 0

Specifying Java or JavaScript Code

In addition to assigning variables and values for an activity input, you can write code in Java or JavaScript to obtain the value for the activity input. You can also write code to perform validation checks on the activity input.

Code can be entered into all activities when surrounded by the following tags:

  • Java: opening java:{ and closing }:java tags
  • JavaScript: opening js:{ and closing }:js tags

Some activities do not require the tags. Java and JavaScript can be entered into the following activities without using the tags:

  • Script Activity
  • Transition Conditions
  • OnEnter/OnComplete Scripts
  • Decision


  1. From the workflow design area, right-click the activity and then click Properties.

    The activity dialog box appears.

  2. On the Inputs tab, from the Value column of the activity input, click <Edit...>.

    The input value dialog box appears.

  3. In the input value dialog box, enter the Java or JavaScript code.
  4. Click OK.


JavaScript example: The GET Client Properties REST API was accessed using the HttpClient activity. If you want to retrieve the client name from the JSON response, type the following script:

var response = JSON.parse(xpath:{/workflow/HttpClient_3/output});
var clName = response.clientProperties[0].client.clientEntity.clientName;

Java example: An activity takes a library entity object as an input, and the ID of the library is stored in a workflow variable. You can obtain the library entity value for the activity by using Java code. The following code gets the library entity for the activity using the workflow variable where the library ID is stored:

#Java Code Sample

commvault.msgs.CvEntities.LibraryEntity libraryEntity = new commvault.msgs.CvEntities.LibraryEntity();
activity.library = libraryEntity;

Java example for a custom activity: A custom activity takes a client entity object as an input. You can obtain the child nodes of the entity object by using Java code: activity.getInput("input_name").getchild_name(). The following code gets the client name child node for the client entity object:

#Java Code Sample for a custom activity


Last modified: 10/13/2017 9:36:12 AM