SetReadonly is not working for choices fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 03:58 AM
I have created one onload client script for impact and choice fields in incident form but it is not working
Onload :
Function onLoad () {
g_form. SetReadOnly ("impact", true) ;
g_form. SetReadOnly ("urgency ", true) ;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 04:27 AM
Hi,
You have an unexpected space in your code.
Should be:
g_form.setReadOnly("field_name",true);
Regards,
Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 04:30 AM
Sry by type mistake I have write same code
g_form.setReadOnly("impact ",true);
But it is nit working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 04:49 AM - edited 09-17-2023 04:52 AM
Hello @siva44 ,
You have an extra space after impact in your code
g_form.setReadOnly("impact",true);
Thank you
G Ramana Murthy
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 09:10 AM
Hi @siva44,
I would suggest to use UI policy to make fields/ columns read only, instead of Client scripts as best practices!
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar