Client script access to variable fields on task records

Variable fields may be accessed via client script on records that are based on the task record.

The most obvious use for this is making Service Catalog variables conditionally display and function in the same way as they did when initially creating an order when they subsequently appear on Request [sc_request], Requested Item [sc_req_item], and Catalog Task [sc_task] records.

The following API is supported via g_form:
  • g_form.setDisplay(name, display)
  • g_form.setVisible(name, visibility)
  • g_form.setMandatory(name, mandatory)
  • g_form.setValue(name, value, display_value)
  • g_form.getValue(name)
  • g_form.setReadOnly(fieldName, boolean)

To specify that a variable is to be the object of the API call, the name must be prefixed with "variables.". This is necessary as another field that is not a variable but has the same name may already be present on the form.

For example, if we ordered an Executive Desktop using the out-of-box Service Catalog, we could add a client script to the Request Item [sc_req_item] to disable the display of the "cpu_speed" variable one would create a client script containing:
g_form.setDisplay("variables.cpu_speed", false);

Hiding mandatory variables

To hide a mandatory variable using a script, the script must first set the mandatory property of the variable to false.