The window object not available in a client script

lawrenson
Giga Contributor

I have written an onChange client script that works in my Development instance, but when I try it in my client's environment it doesn't work.   I am using getReference to pick a value from a form with a callback, and in the callback function updating values that were first defined early in the overall script.   I attached those properties to the window object to make them global and then updated them in the callback functions, then used the values to update my form with setValue.   This works fine in my Dev instance.

Now that I have put the same script into my client's test instance, the script doesn't work and I get an error message:

find_real_file.png

which seems to indicate that the window object doesn't exist.   I thought that the window object was always available in javascript?

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

Hi Steve,



Window is null for service portal and this is the basic condition to identify the UI type for service portal.


Supported and unsupported client scripts


But top is accessible in client scripts.


top.location


top.document.getElementById() ......


View solution in original post

6 REPLIES 6

Gurpreet07
Mega Sage

Check if following working or not


top.window.dLik = '0';


Thanks - I tried


top.dLik = '0';


and that is working.



Thanks very much - it was your comment "top is accessible in client scripts" that got me working.



Steve