g_form.setDisabled('opened_for',false) not working in OnLoad client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 05:03 AM
Hi Everyone,
I have a requirement that I need to show 'loading' message on "Opened For" field and make the field disabled/readonly until I get the response from script include.
I have an onLoad client script to do this, PFB.I 'm able show the 'Loading' message, but unable make the field readonly/disabled.
I Also tried with g_form.setReadOnly('opened_for',true), but no luck, Seems that setDisabled & setReadOnly is not functioning on OnLoad client script.
function onLoad() {
g_form.setValue('opened_for', '-', getMessage('Loading...'));
g_form.setDisabled('opened_for',true);
//Here I'm calling script include
}
Result is:
What I need is like below
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 05:06 AM
Hi there,
Have you also tried using:
g_form.setReadOnly('opened_for', true);
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 05:10 AM
g_form.setReadOnly('opened_for',true);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 08:29 PM
I already tried, its not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 05:13 AM
Hi there,
Just reproduced, and indeed seems like onLoad this does not work. You already mentioned also having tried setReadOnly. Never noticed this. Also because I like to use a UI Policy for onLoad mandatory/read-only like this.
Have you tried a UI Policy?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field