Specify the Network with an Approval Workflow Script

This topics explains how to specify the network for a requested VM through a script embedded in an approval workflow. A user specifies the network when requesting a VM, and the network information is then applied through the use of substitution variables to the VM for use in deployment.

This topic demonstrates how to:

Create a custom attribute

Access through:

Configuration > Custom Attributes

Available to:

Commander Roles of Superuser and Enterprise Admin

Prerequisite: PowerShell must be installed on the machine hosting Commander.

  1. On the Custom Attributes page, click Add.
  2. In the Configure Attribute dialog, do the following:
    1. In the Name field, enter "Network".
    2. In the Type field, select "List".
    3. In the Applies To field, select Services.
    4. Click Next.
  3. On the Configure Attribute page, do the following:
    1. Add "Internal" and "External" as values.
    2. Click Finish.

Add the custom attribute to the New Service Request form

Access through:

Configuration > Self-Service > Forms tab

Available to:

Commander Roles of Superuser and Enterprise Admin

  1. In the Form Library section on the left, under Service Forms, click Default Service.
  2. From the Toolbox section on the right, click Custom/Placement Attribute.

    A custom attribute is added to the service form. By default, it will display the name of the first configure custom attribute.

  3. For the new custom attribute, select Network and keep Required as the default setting.
  4. Click OK.
  5. Click Save.

Create an approval workflow

Access through:

Configuration > Self-Service > Approval tab

Available to:

Commander Roles of Superuser and Enterprise Admin

To create an approval workflow for new service requests, do the following:

  1. On the Workflows page, click Add.
  2. In the Approval and Pre-Provisioning Workflow Configuration dialog, type a name for the approval workflow, and from the Apply This Workflow drop-down list, select When a new request is created. Then click Next.
  3. On the Assignment page, decide whether to apply this workflow as the global default or give specific users or groups access to it, then click Next.
  4. On the Steps page, add an Execute Script step to the workflow, then do the following:
    • Set the script output to capture output as comment.
    • Specify that if the script fails, the step is to be mark as failed.
    • Add the following to the Command line text box:
      powershell -command "& {
      	# Get the network from the request form
      	$network1 = '#{request.services[1].components[1].settings.customAttribute['Network']}';
      	# Write out the correct network label based on the form choice
      	if ($network1 -eq 'internal') {write-host '$NETWORK1=Internal Network$'} 
      	elseif ($network1 -eq 'external') { write-host '$NETWORK1=External Network$' }  
      	else { write-host Unknown value $network1; exit 1 }


    • The variable #{request.services[1].components[1].settings.customAttribute['Network']} works only for single-VM requests. For multi-VM services or multi-VM requests, use this variable in your command line instead:
      where * is the service name. For example:
      #{request.services['Windows Server 2008'].settings.customAttribute['Network']}

    For more on variables, see Using Variables to Access Commander Metadata for Workflows.

    For more on deployment parameters such as $NETWORK$, see Specifying Deployment Parameters Through Substitution Variables.

  5. Complete the rest of the wizard.

Test your workflow

  1. Request a new service, specifying either Internal or External on the Component section of the form.
  2. In Commander, you should see the workflow script executing in the Tasks section.
  3. Click Service Requests and double-click the service request.

    On the Comments tab, you should see the following script output:

    Return Code = 0

    NETWORK1=Internal Network$

    Request Details dialog