In addition to assigning variables and values for an activity input, you can use Java or JavaScript to obtain the value for the activity input, and to validate the activity input.
To include code in an activity, use the following tags:
Java: opening
java:{
and closing}:java
tagsJavaScript: opening
js:{
and closing}:js
tags
The following activities do not require tags:
Script Activity
Transition Conditions
OnEnter/OnComplete Scripts
Decision
Procedure
From the workflow design area, open the properties of an activity.
On the Inputs tab, hover on the input value that you want to add the script to, and then click the open multi-line editor
button.
The Multi-line Editor dialog box appears.
In the box, enter the code.
Click OK.
Examples
Retrieve the Client Name Using the JavaScript
The GET Client Properties REST API was accessed using the HttpClient activity. If you want to retrieve the client name from the JSON response, use the following code:
var response = JSON.parse(xpath:{/workflow/HttpClient_3/output});
var clName = response.clientProperties[0].client.clientEntity.clientName;
Retrieve the Library Entity for an Activity Using the Java Code
An activity takes a library entity object as an input, and the ID of the library is stored in a workflow variable. To get the library entity for the activity using the workflow variable where the library ID is stored, use the following code:
#Java Code Sample
java:{
commvault.msgs.CvEntities.LibraryEntity libraryEntity = new commvault.msgs.CvEntities.LibraryEntity();
libraryEntity.setLibraryId(xpath:{/workflow/variables/libraryId});
activity.library = libraryEntity;
}:java
Retrieve the Client Name for a Custom Activity Using the Java Code
A custom activity takes a client entity object as an input. To get the client name child node using the activity.getInput("input_name").getchild_name()
Java code for the client entity object, use the following code:
#Java Code Sample for a custom activity
java:{
activity.getInput("client").getClientName()
}:java