SetReadonly is not working for choices fields

siva44
Tera Contributor

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) ;

 

 

 

10 REPLIES 10

Niklas Peterson
Mega Sage
Mega Sage

Hi,

You have an unexpected space in your code. 

Should be:

 

 g_form.setReadOnly("field_name",true);

 

Regards,
Niklas

Sry by type mistake I have write same code

g_form.setReadOnly("impact ",true);

But it is nit working 

Hello @siva44 ,

You have an extra space after impact in your code 

g_form.setReadOnly("impact",true);

 

 

 

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer

Sagar Pagar
Tera Patron

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

The world works with ServiceNow