g_form.setVariablesReadOnly(false) not working for all variables in VEditor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 01:16 AM
Hello,
I have tried creating a client script in ritm table so that variables in VEditor won't be read only, I used g_form.setVariablesReadOnly(false); and it only made some fields editable but not all, why is that?
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 01:41 AM
Hi,
Usually you need to have catalog client script so that the script runs only for particular catalog item and not for all catalog items
1) Applies to -> catalog item
2) type -> onLoad
3) Catalog item -> your catalog item
in script add that code
function onLoad(){
g_form.setVariablesReadOnly(false);
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
03-04-2020 01:57 AM
Hi,
I have tried this, and it's not working because we have a client script in the RITM table that sets all the variables in veditor to read-only. That's why I am trying to create another client script in the RITM table to make some fields editable however, it's not working on some variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 02:16 AM
Hello,
The order of onLoad catalog client script should be greater than all other catalog client script and catalog UI policies.
Regards,
Sagar Pagar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 02:53 AM
Hi Sagar,
I tried setting the order to the highest and still some fields are not editable in the veditor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 02:45 AM
Hi Raphael Dizon,
You can use this-
For fields on the form use g_form.setReadOnly('<fieldName>', true);
For catalog variables use g_form.setReadOnly('variables.<variableName>', true);
Or you can go through it -
https://hi.service-now.com/kb_view.do?sysparm_article=KB0752560
If this solves your problem please mark helpful or correct.
Thanks
Swapnil Soni