Building a dynamic select option list

You can build a list of select element options dynamically from a callback response array supplied by the ISV cloud service.
An example of when you might use callback options is if you want a user to select one of several ISV-specific policies to apply to a device or a tenant. In this case, you would create a callback to respond with an array containing all the available policies for that device or tenant. The callback request can include UI values to refine the search results.

To build a dynamic select option list

  1. Select the Callback tab in the Options section.

  2. Select the appropriate callback from the Callback name dropdown.

    Note

    As with all callbacks, you must have already created the callback. You must also write code for the CyberApp callback handler to handle the callback. The response payload must include an array of items.

  3. [If the callback requires UI data for the request payload] Map the callback request payload.

  4. The three select options fields for mapping the callback response array are Name (equates to the Label field in Static options), Value, and Comment.

    Important

    The three mappable fields of a select element can only be mapped with properties from a single array in the response payload: you cannot map them across two or three different arrays. Name and Comment can only be mapped to string types. Value can be mapped to a string or a number type.

Tip

You can automatically pre-select a value by creating an input parameter with the desired pre-select value and the same ID as the select element.

Example

In this example, the user chooses the policy they want to apply to the tenant through a select element. A callback named GetTenantPolicies retrieves the possible policies for the tenant from the ISV cloud service. To refine the search, we pass the Acronis tenant_id to the service as the callback request payload. To map this value to the callback request, we create an input parameter for the Root form, and assign it the value of the Acronis system variable.

In the Request mapping section, we map the tenantid input parameter (which has been assigned the value of the Acronis tenant_id variable) to the callback request property tenantcode.
In the Response mapping section, we map:
  • the callback response property policydescription to the select’s Comment field.

  • the callback response property policycode (which is a number) to the select’s Value field.

  • the callback response property policyname to the select’s Name field.

Note

The request and response payload of the GetTenantPolices callback at listed at the bottom of the page.

../../../../../../../_images/ss-element-selectcallback.gif

The GetTenantPolicies callback

GetTenantPolicies callback has the following request payload:

{
  "type": "object",
  "$schema": "http://json-schema.org/draft-04/schema",
  "properties": {
    "items": {
      "type": "object",
      "properties": {
        "tenantcode": {
          "type": "string"
        }
      }
    }
  }
}

GetTenantPolicies callback has the following response payload:

{
  "type": "object",
  "$schema": "http://json-schema.org/draft-04/schema",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "policycode": {
            "type": "number"
          },
          "policyname": {
            "type": "string"
          },
          "policydescription": {
            "type": "string"
          }
        }
      }
    }
  }
}