Notifications

9 views

Issue

Symptoms

Cannot instantiate a Script Include object from a client script.  Error in console displays something like:

ReferenceError: HelloWorld is not defined

Where HelloWorld is the name of the Script Include

On the Client Script or UI Policy, we may have something like

var obj = new HelloWorld();

Release

All

Cause

The problem is the way client code is being prepared to call the Script Include

var obj = new HelloWorld()

is not the correct way to instantiate a Script Include object

 

Resolution

The correct way to call a Script Include from a Client Script, or other client side code like UI Policies, is to use a GlideAjax object like so:

var ga = new GlideAjax("HelloWorld")

Additional Information

https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/GlideAjax/concept/c_GlideAjaxAPI.html

Article Information

Last Updated:2019-08-02 20:38:57
Published:2019-07-19