RUNSUB
![]() |
Calls a subscript, which runs and then uses RETURN to return to and continue running the main script.. |
Supported Script Types
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Generic | Chat | Phone | Voicemail | Work Item |
Properties
- ScriptName
- The name of the subscript you are referencing. Though you can manually type in the path of the script, the best practice is to use the Choose Script link at the top of the properties window.
- ReturnVariable
- The value that is returned from the subscript and stored.
- Parameters
- The value in this property indicates the number of parameters to send to the sub script. Parameters are named P1 through Pn (where n is the Param Count). The value you enter in this property determines the number of Pn fields that become available to enter parameters for this script.
Branches
- Default
- Branch taken unless the script meets a condition that requires it to take one of the other branches. It is also taken if the other branches are not defined.
- OnError
- The branch the script will take if the subscript cannot be found.
Tips and Tricks
- This action can especially be useful if you have one or more larger scripts that you'd rather break into smaller scripts.
- When the subscript runs, it stores a value in the ReturnValue property of the RETURN action and then passes that value back to the ReturnVariable property in the RUNSUB on the main script.
- The main script type and the subscript type must be the same, for example, main script is a phone script, so the subscript must also be a phone script.
- If you put a RUNSUB action in the main script, your subscript MUST have a RETURN action.
- The main script and the subscript must be in the same folder.
- RUNSUB can pass multiple variables from the main script to the subscript, but the subscript can return only one value (in the ReturnVariable property) to the main script.
- The value that is returned to the main script is stored in the ReturnVariable property
- Any variables defined in the sub script will no longer be available when the subscript terminates.
- To pass multiple values, use an array.
Phone Script Example Using RUNSUB
In the main script below (shown top), when the script is triggered, the RUNSUB action immediately triggers the subscript (shown bottom). In the subscript, VOICEPARAMS sets the Text-to-Speech settings, and the HOURS action sets branches for open, closed, and holiday to three different RETURN actions. When the subscript is finished, the values in the ReturnValues property (in the RETURN action) are stored in the ReturnVariable field (RUNSUB action in the main script). The CASE action then sets the open, closed, and holiday branches as appropriate.
Main Script
Would you like to download this script?
Subscript
The three RETURN actions provide values in the ReturnValue property so the CASE action is the main script can determine which branch to follow.
Would you like to download this script?