- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 07:44 AM
i am using attached conditions and script but its not making variables read only on RITM
what could be the case ?
Please help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 08:14 AM
Hi @karan15
Please use something like this
function onLoad() {
g_form.setVariablesReadOnly(true);
}
UI Type: ALL
If above information resolved your issue, please don't forget to mark correct or helpful.
Regards
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 08:14 AM
Hi @karan15
Please use something like this
function onLoad() {
g_form.setVariablesReadOnly(true);
}
UI Type: ALL
If above information resolved your issue, please don't forget to mark correct or helpful.
Regards
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2023 06:16 PM
thanks Devender this worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 08:21 AM
Copied from the KB0752560
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0752560
Description
Trying to make a Variable Editor on the incident table read-only does not work with the setVariablesReadOnly method.
Steps to reproduce:
- Create an onLoad client script on the Incident table with g_form.setVariablesReadOnly as true
- Open the Incident form that has the variable editor
- 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:
- Create a Client Script on the Incident table
- Paste the following script:
function onLoad() { $("variable_map").querySelectorAll("item").forEach(function(item){ var variable = item.getAttribute("qname"); g_form.setReadOnly("variables."+ variable, true); }); }
- 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)
- To do that right click in the header -> Configure -> Form Layout
- On the left side find "Isolate script" and bring it to the right and save
- Save changes
This should make the Variable Editor on the incident table read-only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @karan15 ,
Ideally Variables don't have the option to make read only.
You have to create an onload client ,
Also check the: