Set Variables readonly on RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2021 07:35 PM
Hi Community
I need help for the below requirement
I want to make the variables read-only on the RITM form. I wrote a UI policy on the RITM table please find it below
This is working, but I have some variables for which the "Name" starts with "Edit_" should be editble on the RITM.
I have tried the below code, but it is not working
g_form.setReadOnly('variables.nameLIKEEdit^active=true','false');
Can you please help me if there is a way to fix this
Thanks in advance
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2021 12:02 AM
Hi,
then you need to do this
1) normal client script on sc_req_item table
Ensure this
1) Isolate Script field is set to false on this client script
2) if this field is not on form then from list you can make it false
This will make all variables readonly except those whose name starts with edit
example: edit_user, edit_group etc
function onLoad() {
$("variable_map").querySelectorAll("item").forEach(function(item){
var variable = item.getAttribute("qname");
if(!variable.startsWith('edit')){
// if not starts with edit then make those readonly
g_form.setReadOnly("variables."+ variable, true);
}
});
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2021 10:26 AM
Hi
I have tried the above mentioned script, but it is not working. And I came to know that SetReadOnly API is not working on the current versions of Servicenow.
Is there any other way to fix this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2021 10:33 AM
I have tried the API mentioned below
g_form.setVariablesReadOnly(true);
Still its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2021 10:21 PM
Hi,
this script should work fine in normal client script on sc_req_item table
g_form.setVariablesReadOnly(true);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2021 12:48 AM
Hi
This is working now
But I have a catalog item for which the variables should be editable only for a particular group. The client mentioned above is setting all the variables readonly- but I made them editable through catalog UI policy, but they are editable to everyone.
I want all the varaibles of that catalog item editable on the RITM level only for that particular group.
Any suggestion on this ?
Thanks in advance
Sandeep