Notifications

515 views

Description

Trying to make a Variable Editor on the incident table read-only does not work with the setVariablesReadOnly method.

Steps to reproduce:

  1. Create an onLoad client script on the Incident table with g_form.setVariablesReadOnly as true
  2. Open the Incident form that has the variable editor
  3. Notice the variables in Variable editor on Incident are still editable

Release or Environment

Kingston, London, Madrid

 

Cause

The setVariablesReadOnly method is specifically reserved for the sc_task and the sc_req_item table.  Will not work with any other table

Resolution

To set the Variable Editor to read only a different table like incident, please follow these steps:

  1. Create a Client Script on the Incident table
  2. Paste the following script:
    function onLoad() { 
    $("variable_map").querySelectorAll("item").forEach(function(item){
    var variable = item.getAttribute("qname"); 
    g_form.setReadOnly("variables."+ variable, true); 
    }); 
    }
  3. This will require to uncheck (set to false) the "isolate script" checkbox (This checkbox is not on the form by default) Steps below how to bring it to the form)
    1. To do that right click in the header -> Configure -> Form Layout
    2. On the left side find "Isolate script" and bring it to the right and save
  4. Save changes
    This should make the Variable Editor on the incident table read-only

Additional Information

This script can be found in the documentation: Service Catalog variable editors

Article Information

Last Updated:2019-09-12 16:37:09
Published:2019-09-12