g_form.setReadOnly('variable',true); not working in RITM level using on load Client script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2018 08:27 PM
Hi Team,
I am using an On Load Client script to set a variable ReadOnly. The field is in the variables section, and it's not setting to readonly.
its silly but could n't figure out what is the issue... I have checked the UI policies, other client scripts and there is no collision happening.
Please let me know what could be the issue.
Regards,
Suresh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2018 03:25 AM
If this does not work, then check two places
1.catalog client script where applies on ritm is marked true,
2. acls where it is conflicting with roles.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2018 02:52 AM
Hi Suresh,
In screenshot you have the set the script as Active = false. Could you please check if the script is Active and use
g_form.setReadOnly('variables.service_da_required',true).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2018 02:59 AM
Use the below
g_form.setReadOnly('variables.service_da_required',true);
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2018 11:13 PM
Hi Suresh,
For fields on the form use g_form.setReadOnly('<fieldName>', true);
For catalog variables use g_form.setReadOnly('variables.<variableName>', true);
Mark Correct if this solves your issue and also hit Like and 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
08-26-2021 11:59 PM
Thanks Ankur.