Workflow Variables

1 minute read

This post is about Commvault Workflow variables. Variables are not too difficult normally, but in the context of Workflows we are passing variables between different components. For example, there may be variables input/output from PowerShell, SQL Query, Qscript, Input, etc… How to make them all happy?

For example, variables user-inputed as input into a PowerShell script will get translated as one total string rather than variables separated by strings denominated by a comma (,). This was solved by taking the input and modifying the Powershell code to use the split function to handle this.

This ensured passing of variables from the user interface for anything separated by commas would be handled as independent variables such as the disk numbers and MediaAgents. The variables looked as follows in Powershell,

param ([String[]] $disks, [String] $dir, [String] $lib, [String] $ma,[String[]] $ma2s,[String] $user,[String] $psswd,[switch] $add)

$MountDirectory = $dir

Once translated into Workflow world they looked as follows.

$disksIn = "xpath:{/workflow/PopupInput_1/Disks}"
$dir = "xpath:{/workflow/PopupInput_1/AutomatedMountPath}"

#param ([String[]] $disks, [string] $dir, [String] $lib, [String] $ma,[String[]] $ma2s,[String] $user,[String] $psswd,[switch] $add)

$disks = $disksIn -split ","
#$ma2s = $ma2sIn -split ","

Now, what about the inputs coming in from standard Commvault qoperation execscript? Well, this is just a matter of adding qoperation execute and swapping Workflow input variables into the input xml as such.

<EVGui_ConfigureStorageLibraryReq isConfigRequired="1">
    <library baseFolder="CVDiskFolder" libraryName="xpath:{/workflow/PopupInput_1/LibraryName}" mediaAgentId="" mediaAgentName="xpath:{/workflow/PopupInput_1/MediaAgent}" mountPath="xpath:{/workflow/PopupInput_1/AutomatedMountPath}" opType="1"/>
</EVGui_ConfigureStorageLibraryReq>