When you customize a Service Broker request form, you can base the behavior of some fields on the results of a vRealize Orchestrator action.

There are several ways that you can use vRealize Orchestrator actions. You might have an action that pulls the data from a third source, or you can use a script that defines the size and cost.

The first example is based on manually added fields so that you understand the underlying process. The second example uses the same premise, but instead relies on a template field.

The third example is based on a custom option that is added to the catalog request form, where the user selects a folder based on the results from a custom vRealize Orchestrator action.

The fourth example uses vRealize Orchestrator workflow attributes to customize a field in the request form.

In addition to the following examples, other examples are available in the VMware Cloud Management blog.

Size and cost as manually added fields example

In this use case, you want the catalog user to select a virtual machine size, and then display the cost of that machine per day. To do this example, you have a vRealize Orchestrator script that correlates the size and cost. You then add a size field and a cost field to the template custom form. The size field determines the value that appears in the cost field.

  1. In vRealize Orchestrator, configure an action named getWindows10Cost.
    Example of a vRealize Orchestrator Action with Size and Cost
  2. Add a script.

    You can use the following example script.

    var cost = "Unknown";
    switch(deploymentSize) {
    	case 'small' : cost = "$15";break;
    	case 'medium' : cost = "$25";break;
    	case 'large' : cost = "$45";break ;
    	default : break ;
    return cost;
  3. Add deploymentSize as an input string.
  4. In Service Broker, add and configure a Size field to a template custom form.

    Configure the size field as a drop-down element with Small, Medium, and Large values.

    Populated size field values in the custom form.

    On the Values tab, configure the following property values.

    • Default value = Large
    • Value options
      • Value source = Constant
      • Value definition = small|Small,medium|Medium,large|Large
  5. Add the cost field as a text field to display the cost as defined in the vRealize Orchestrator action based on the value selected in the size field.
    Populated cost field value in the custom form.

    On the Values tab, configure the following property values.

    • Default value = External source
    • Select action = <your vRealize Orchestrator actions folder>/getWindows10Cost
    • Action inputs
      • deploymentSize. This value was configured in the action as the input.
      • Field
      • Size. This is the field that you previously created.
  6. Enable the custom form and save it.
  7. To verify that it is working, request the item in the catalog. You should see the Cost field populated based on the selected Size value.
    Populated example in the catalog

Cost based on schema element example

In this use case, you want the catalog user to see the cost of that machine per day based on the flavor property in the template. To do this example, you use the vRealize Orchestrator script from the previous example. But in this use case the cost is based on the flavor size that your user selected in the custom form when they request the Service Broker catalog item.

The simple example template includes a size input field where the user selects the flavor property.
Example of inputs for flavor mapping in the template
The custom form uses the field, named Select machine size in this example.
Value options in the custom form designer
The cost deploymentSize input is based on the Select machine size field.
Cost based on the schema size field in the catalog request

Destination folder based on a custom action example

In this use case, you want the catalog user to select from the folders that are available to them when they move a machine from one folder to another. To do this example, you create a custom action in vRealize Orchestrator that returns folders available to the user requesting the action from the catalog. You then customize the Destination folder field in the catalog request form.

In the catalog, the Move virtual machines to folder workflow that is used in this example is exposed as a custom resource action created in Cloud Assembly.

  1. In vRealize Orchestrator, create an action named getFolderForUser.
    1. On the Script tab, add action inputs, select the return type of the output, and add a script.

      You can use the following example script.

      var parentTargetDirName = "users";
      var sdkConnection = VcPlugin.findSdkConnectionForUUID(vcUuid);
      var rootFolder = sdkConnection.getAllVmFolders(null, "xpath:matches(name,'" + parentTargetDirName + "')")[0];
      var result = new Array();
      for each(var folder in rootFolder.childEntity) {
          if (folder instanceof VcFolder && folder.permission.length > 0) {
              var entityPrivilege = sdkConnection.authorizationManager.hasUserPrivilegeOnEntities([folder], username, ["System.Read"])[0];
              if (entityPrivilege.privAvailability[0].isGranted) {
      return result;
    2. When you finish editing the action, click Save.
  2. In Cloud Assembly, create a custom resource action named ChangeFolder.
    1. Select the Cloud.vSphere.Machine resource type.
    2. Select the Move virtual machines to folder workflow.
  3. Customize the request form that users see when they request the action.
    1. Open the ChangeFolder action.
    2. Click Edit Request Parameters.
    3. Customize how the Destination folder field is presented to users.
      Value options Sample value
      Value source External source
      Select action getFolderForUser
      Action inputs

      username Field

      Click Select string > Request info fields > Requested by.

      Click Select.

      Action inputs


      Click Select string > Request info fields > Resource properties > vCenter UUID.

      Click Select.

    4. Click Save.

When a user requests the action in the catalog, they can select a destination folder for the virtual machine from the folders that are available to them.

Hostname based on workflow attributes example

In this use case, you want to customize the URL field in the request form using vRealize Orchestrator workflow attributes. To do this example, you need a vRealize Orchestrator workflow with an attribute or variable that has either a constant value or is bound to a configuration element. The attribute or variable must have an initial value set because the binding is done before you run the workflow.
  1. In vRealize Orchestrator, create or clone an existing workflow. For example, clone the Add a REST Host workflow.
    1. On the Variables tab, add a variable and bind it to a configuration element.
      Value options Sample value
      Name hostname
      Type string
      Configuration Enable the Bind to configuration option.

      In the Configuration text box, select the configuration that you want to bind the variable to. For example, select the custom vRO Configuration: hostname element.

    2. Save the workflow.
  2. Import the workflow in Service Broker.
  3. Customize the request form.
    1. Click the URL element in the form designer.
    2. On the Values tab, set the value source to Bind field.
    3. Click Value Field > Request info fields.
    4. Select the hostname variable or any of the available workflow attributes.
  4. Save and enable the form.

When a user requests the workflow from the catalog, the URL field is populated based on the hostname variable.

If you switch to a different project, the workflow attributes are recalculated because the workflow might come from a different vRealize Orchestrator integration.