Running SBM ModScript from an Orchestration

You can use the RunModScript Application Engine Web service call from a Service step in an orchestration to execute SBM ModScript.

For example, in an orchestration, you might want to invoke a script from the command-line, read/write data to a file, or update an item with text. You can have an orchestration call SBM ModScript for any of these tasks and more.

The sbmappservices72 WSDL exports a RunModScript function that the Orchestration Engine can invoke. The interface allows the caller (Orchestration Engine) to provide input to the ModScript via an "inputs" data array; and allows ModScript to send output to the caller via an "output" data array. As such, you can fully incorporate a ModScript as a Service step in an orchestration.

Note that even though the orchestration may be initiated by an item transition, ModScript will not have a Shell.Item(). Instead, the Orchestration Engine can send the item's tableID:itemID as a parameter to the ModScript. The script could reference this input to read the item as a custom variable.

For details on the RunModScript Web service call, refer to the SBM Web Services Developer's Guide.

For details on programming with SBM ModScript, refer to the SBM ModScript Reference Guide.

Example: Running a Batch File

In the following example, the "LaunchBat" orchestration contains a Service step that calls the RunModScript Web service, which runs a ModScript called "LaunchBatFile" that executes a simple batch file.

"LaunchBatFile" ModScript added to the list of Scripts in SBM Composer:

image

Contents of run.bat, which is saved in C:\Program Files\Serena\SBM\Application Engine\ModScript:

@ECHO off
REM --- run.bat
REM --- This is an example batch program to be called
REM --- from the SBM ModScript example "Launch.tsc"
REM --- It appends a new line to C:\out.txt each time it runs
ECHO Launched run.bat, params (if any): %* >> "C:\Program Files\Serena\SBM\
Application Engine\ModScript\out.txt"

RunModScript Service step in the "LaunchBat" orchestration workflow:

image

image

Note: In the RunModScript call, you can send any one of the elements in scriptId—you do not need to provide values for every element. You only need to provide more than one element in the event that the first element does not uniquely identify the script.

In the Calculate step, the RunModScript response is concatenated to hard-coded text in the Result target:

image

image

The item's Title field is updated via the TransitionItems Web service call:

image

image

SBM item showing the result in the Title field:

image

The output.txt file results:

Launched run.bat, params (if any): 1007:3 ItemID=