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

Fair point, I tend to use it in small scripts with arrays as the efficiency loss is minor and its cleaner to write.

Taking a second look at your code, it's possible that your array is holding field names and not field labels. When referencing a field in scripts you must use their labels. 

 

*Edit
There is also the possibility that the user you are impersonating to test this script is not in the correct groups

The array is holding field names and the same code works when I use setMandatory method, but something is stopping the setReadOnly and I need a way to know what it is that is preventing the setReadOnly from working, what's strange is that the setReadOnly works when I run it on the pop up JavaScript Executor on the form. I have removed the user condition and it still has the same issue.

Are you working in a scoped application? some other community posts asking about g_form.setReadOnly() have identified that g_form only works in the global scope, and not in custom scopes.

Nope, it is written on the Global Incident table.

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