By following the procedure detailed in this article, you can run a Command Workflow from Approval Workflows and Completion Workflows. When doing so, you will define a wait time for the step calling the other workflow, and a timeout for the workflow itself to run. This means you should understand the typical run time of the Command Workflow before configuring it as a workflow step.

You can use this procedure to install applications on top of default OS installations; form controls allow users to specify what to install.

In this example, a Custom Attribute on the request form allows the requester to choose which version of SQL to install, and conditional workflow steps are configured to run based on the selection made. Each version of SQL supported would have its own Command Workflow created previously, outside the scope of this article.


Requirements



Download the Call Workflow script and extract it to a location on the vCommander application server from which it will be called by the workflow step described below.


Creating the Custom Attribute


This solution requires a custom attribute be exposed via the Service Portal.

  1. Under the Configuration menu, choose Custom Attributes.
  2. Click Add.
  3. Enter a name like SQL Version and provide a meaningful description.
  4. Choose to apply the attribute to Form and select the List radio button to set the type.
  5. Check Edit in Service Portal.

  6. Click Next.
  7. Add the options you wish to make available, using the Move Up and Move Down buttons to sort your list.

For each service that will include a choice of databases, add the attribute to the appropriate component, optionally setting a default value.

Also make sure that the the specific control for the custom attribute has been added on the Form tab.

Creating the Workflow Step


You can use this solution in Approval Workflows and Completion Workflows, but the example below only covers the latter. The configuration is identical for Approval Workflows.

  1. Under the Configuration menu, choose Service Request Configuration.
  2. Switch to the Completion Workflow tab.
  3. Click Add.
  4. Provide a Name and choose to apply this workflow after a VM is deployed. Click Next.
  5. Click AddExecute Script.
  6. Provide a Name indicating which version of SQL it installs.
  7. Beside Step Execution choose Execute when conditions are met and click Edit. Enter the condition below, where MS-SQL 2008 is the name of the command workflow being called. Click OK.
    #{target.settings.inputField['SQL Version']} -eq "MS-SQL 2008"


  8. Set the Timeout to an appropriate wait time in seconds. Note that this time must be greater than the timeout specified in the command line for the script below.
  9. Set Script Output to Capture script output as comment, and When Step Fails to Mark workflow step as failed: do not proceed.
  10. Enter the following command line:
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe & c:\Scripts\CallWorkflow.ps1 -VMID '#{target.Id}' -WorkflowName "Install MS-SQL 2008" -Timeout "30"

    Replace c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe with the full path to the PowerShell executable on the vCommander server.
    Replace c:\Scripts\CallWorkflow.ps1 with the full path to the Call Workflow Script on the vCommander server.
    Replace “Install MS-SQL 2008″ with the name of the workflow that will be run, as it appears in vCommander, in quotes.
    Replace “30” with a value in seconds to use as the timeout for the script to run. This number must be smaller than the timeout for the step itself, as configured above.

  11. Click Next.
  12. Select Apply this workflow to the selected components and choose components that include the custom attribute on the form (and also support Microsoft SQL 2008). Click Next.
  13. Click Finish.

Repeat the same process to make conditional workflow steps for each choice you’ve exposed using the custom attribute.