A catalog item Multi Line Text variable cannot be hidden by setDisplay() in a client script if read-only. This occurs when it is viewed in the variable editor on a Requested Item form after checkout.

Conditions for the error to happen:
-Variable has to be defined on the item directly. Similar variables inside Variable Sets do work correctly. Wrapping the variable in a container doesn't help.
-Variable has to be Multi Line Text. Other types work, such as Single Line Text.
-Variable has to be read-only by means of Write Roles defined on the variable. (and possibly other methods)
-The RITM form needs to be viewed by a user who has the variable set read-only by the write-role.

Steps to Reproduce

  1. Login in to an instance on the Dublin version of Servicenow.
  2. Create a Catalog Item.
  3. Add a new Multi line text variable to it named var_1.
  4. Set this variable with Write Roles=admin, to make it read-only to non-admin users.
  5. Create a Client Script on Task to run the following:
    g_form.setDisplay('variables.var_1', false);
  6. Order the catalog item, leaving the variable blank.
  7. Impersonate a non-admin user.
  8. View the RITM you just ordered in a form, in default view, so the variable editor is on the form.
    Result:  The variable should be hidden, but it is not.


Try any of the following workarounds:

  • Use Single Line Text instead of Multi line text
  • Do not set the field read-only, but simply hide it instead
  • Move the affected variables into a Variable Set

The last option is the preferred workaround. With this option, all you need to do is create a variable set and point the variable to this instead of the catalog item. If the variable set has the same order set as the item and is then added to the catalog item, nothing will have changed from the point of view of the variable sys_id, or how it is subsequently used and displayed to the user. This option also does not break any existing RITMs as the sys_id of the variable remains the same.

Related Problem: PRB628304

Seen In

Dublin Patch 6
Fuji Patch 6
Geneva Patch 3

Fixed In


Associated Community Threads

There is no data to report.

Article Information

Last Updated:2016-03-31 16:32:11