You create a custom form when the default form provides too much or too little information to the requesting user. You can add more fields to the form, you can hide fields on a form, or you can pre-populate fields and either show or hide them.

This use case is based on a blueprint that contains a vSphere virtual machine type and an XaaS blueprint that configures an Active Directory administrator account on the virtual machine. The XaaS blueprint is based on the Create a user with a password in a group workflow.

Your goal in this use case is to:

  • Give the user the option to configure the administrator password.

  • Preconfigure the machine details so that CPU and memory values are both based on GB.

How do you benefit from this use case? The use case includes examples of the following form customizations:

  • Add specific fields to a blank form.

  • Configure a show/hide check box.

  • Hide fields until the requesting user selects a check box.

  • Add validation to fields.

  • Display a memory field in GB even though the blueprint field is calculated in MB.

  • Use regular expressions.

Prerequisites

  • Log in to vRealize Automation as an application architect, software architect, or infrastructure architect.

  • Create a YourCo Machine and User blueprint that includes a vSphere blueprint and an XaaS blueprint to create an Active Directory user account with a password in a group. For an example, see Create an XaaS Blueprint for Creating a User.

Procedure

  1. Select Design > Blueprints.
  2. Highlight the row containing YourCo Machine and User blueprint and click Custom Form > Edit.
  3. Rename the General tab.
    1. Click the tab.
    2. In the Title property in the right property pane, enter Configuration.
  4. On your new Configuration tab, add and configure the following fields with the provided values.

    Custom Form Configuration Tab Example

    Use the provided Appearance, Values, and Constraints values.

    Resolves any errors as you build the form.

    Field in Screenshot

    Blueprint Element Source

    Appearance

    Values

    Constraints

    Deploy Machine with Active Directory User Account

    Generic Elements > Text

    Label and type

    • Display type = Text

    Visibility

    • Value source = Constant

    • Visible = Yes

    Default value

    • Default value = Deploy Machine with Active Directory User Account

    • Value source = Constant

    Reason for Request

    Blueprint Elements > vSphere_vCenter_Machine > Description

    Label and type

    • Label = Reason for request

    • Display type = Text Field

    Visibility

    • Value source = Constant

    • Visible = Yes

    Read-only

    • Value source = Constant

    • Read-only = No

    Custom help

    • Signpost help = Provide the reason for your request.

    Required

    • Value source = Constant

    • Required = Yes

    Number of Deployments

    Blueprint Elements > General > Number of Deployments

    Label and type

    • Label = Number of Deployments

    • Display type = Integer

    Visibility

    • Value source = Constant

    • Visible = Yes

    Read-only

    • Value source = Constant

    • Read-only = No

    Custom help

    • Signpost help = Select the number of instances of the blueprint to deploy.

    Default value

    • Value source = Constant

    • Default value = 1

    Required

    • Value source = Constant

    • Required = Yes

    Minimum value

    • Value source = Constant

    • Min value = 1

    Add Active Directory account check box

    Generic Elements > Checkbox

    Label and Type

    • Label = Add Active Directory account.

    • Display type = Checkbox

    Visibility

    • Value source = Constant

    • Visible = Yes

    Username

    Blueprint Elements > Create a user with a password in a group > The account name for the user

    Label and type

    • Label = Username

    • Display type = Text field

    Visibility

    Note:

    This visibility property, configured the same way in the subsequent fields, hides the field unless the Add Active Directory account check box is selected.

    • Value source = Conditional value

    • Expression =

      Set value = Yes

      If Add Active Directory account Equals Yes

    Custom help

    • Signpost help = Provide the administrator user name.

    Default value

    • Value source = Constant

    • Default value = admin

    Required

    • Value source = Constant

    • Required = Yes

    Regular expression

    Note:

    The regular expressions must follow the JavaScript syntax.

    • Value source = Constant

    • Regular expression = "^[a-z]*$"

    • Validation error message = Your user name must not contain any special characters or numbers.

    Password

    Blueprint Elements > Create a user with a password in a group > The password to set for the newly created account

    Label and type

    • Label = Password

    • Display type = Password

    Visibility

    • Value source = Conditional value

    • Expression =

      Set value = Yes

      If Add Active Directory account Equals Yes

    Custom help

    • Signpost help = Provide the password for your administrator account.

    Required

    • Value source = Constant

    • Required = Yes

    Regular expression

    • Value source = Constant

    • Regular Expression = "^(? = .*[A-Z])(? = .*[0-9])(? = .*[a-z]).{8,}$"

    • Message = Your administrator password must be at least eight characters and can include alphanumeric and special characters.

    Confirm password

    Blueprint Elements > Create a user with a password in a group > Confirmation of the password

    Label and type

    • Label = Confirm password

    Display type = Password

    Visibility

    • Value source = Conditional value

    • Expression =

      Set value to Yes

      If Add Active Directory account Equals Yes

    Custom help

    • Signpost help = Reenter the password for your administrator account.

    Required

    • Value source = Constant

    • Required = Yes

    Match field

    • Match field = Password

    Email

    Generic Elements > Text Field

    Label and type

    • Label = Email

    • Display type = Text Field

    Visibility

    • Value source = Conditional value

    • Expression =

      Set value = Yes

      If Add Active Directory account Equals Yes

    Custom help

    • Signpost help = Provide the administrator email.

    Default value

    • Value source = Computed value

    • Operator = Concatenate

    • Add value = Field. Select Username

    • Add value = Constant. Enter @yourco.com

    Regular expression

    • Value source = Constant

    • Regular expression = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$"

    • Validation error message = Provide valid email.

    I have read and accept the software policy check box.

    Generic Elements > Checkbox

    Label and type

    • Element label = I have read and accept the software policy

    • Display type = Checkbox

    Visibility

    • Value source = Conditional value

    • Expression =

      Set value = Yes

      If Add Active Directory account Equals Yes

  5. Click Add Tab and entering Machine Details in the Title property to the right.
  6. Configure the following fields in the Machine Details tab.

    Custom Forms Machine Details Tab Example

    Use the provided Appearance, Values, and Constraints values.

    Field in Screenshot

    Blueprint Elements Source

    Appearance

    Values

    Constraints

    Storage (GB)

    Blueprint Elements > vSphere_vCenter_Machine > Storage (GB)

    Label and type

    • Label = Storage (GB)

    • Display type = Integer

    Visibility

    • Value source = Constant

    • Visibility = Yes

    Read-only

    • Value source = Constant

    • Read-only = No

    Default value

    • Value source = Constant

    • Default value = 4

    Minimum value

    • Value source = Constant

    • Minimum value = 2

    Number of CPUs

    Blueprint Elements > vSphere_vCenter_Machine > CPUs

    Label and type

    • Label = Number of CPUs

    • Display type = Integer

    Visibility

    • Value source = Constant

    • Visibility = Yes

    Default value

    • Value source = Constant

    • Default value = 1

    Minimum value

    • Value source = Constant

    • Min value = 1

    Memory (GB)

    Generic Elements > Integer

    Label and type

    • Label = Memory (GB)

    • Display type = Integer

    Visibility

    • Value source = Constant

    • Visibility = Yes

    Default value

    • Value source = Constant

    • Default value = 1

    Minimum value

    • Value source = Constant

    • Minimum value = 1

    Memory (MB)

    Blueprint Elements > vSphere_vCenter_Machine > Memory (MB)

    Label and type

    • Label = Memory (MB)

    • Display type = Integer

    Visibility

    • Value source = Constant

    • Visibility = No

    Default value

    • Value source = Computed value

    • Operator = Multiply

    • Add Value = Field. Select Memory (GB)

    • Add Value = Constant. Enter 1024

  7. Resolve any errors. You can save the form but you cannot activate it until the form is free of errors.
  8. To save the form and close the form designer, click Finish.
  9. Select the blueprint and click Publish.
  10. To make the custom form available when users request the item in the service catalog, on the Blueprints page toolbar, select Custom Form > Activate.

What to do next

  • Make the blueprint available in the service catalog. See Managing the Service Catalog.

  • In the catalog, verify that the request form is similar to the following example.

    Example of a custom form in the catalog