Client Script g_form.setReadOnly() not working.

JavaScriptMaest
Giga Contributor

g_form.setReadOnly() method not working when I run it through Client Script, but it works when I run the same on the JavaScript Executor(Ctrl + Alt + Shift + J), is there a way to debug and know what is stopping my Client Script code to not work on setting the field read only. 

The Client Script is:

 

find_real_file.png

1 ACCEPTED SOLUTION

Are there any UI policies that are conflicting with your client script?

View solution in original post

24 REPLIES 24

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Rahul,

Can you share your script here?

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

find_real_file.png

Allen Andreas
Administrator
Administrator

Hi,

This could be for many reasons. As Derek asked...please include your script otherwise we're all speculating and wasting time.

It could be other conflicting client scripts or UI policies that you have.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Here it is,

find_real_file.png

nataliya_b
Tera Guru

are there any mandatory fields?

add this line before setting readonly 

g_form.setMandatory(item, false);