Notifications

16 views

Symptoms


Client scripts accessing global objects such as 'document' are not working in scoped applications. 

Console warning about the global object being null.

Example: TypeError: Cannot read property 'document' of null 

Cause 


There was a security change to remove those global from scoped applications, but you can disable this by setting a sys_property in that scope "glide.script.block.client.globals". See KB0551586 for full details.

Resolution


If you are still having issues even after setting that property, you may be incorrectly accessing the global objects using the 'this' keyword. In global client scripts, you can access the objects using this.

Example: this.document.getElementById('')

 

But in Scoped client script, the 'this' keyword is not available, so you need to access the globals directly.

Example: document.getElementById('')

Additional Information 


This community post has some additional information

https://community.servicenow.com/community?id=community_blog&sys_id=788c66e1dbd0dbc01dcaf3231f961969 

Article Information

Last Updated:2018-11-28 09:56:18
Published:2018-11-28