Notifications

22 views

Symptoms

A custom UI Action is not working as expected. When the UI Action is script is executed there is following error seen in the browser console:

Uncaught TypeError: Cannot read property 'apply' of undefined

 

Release

All

 

Cause

This occurs when you have the following statement in your code:

var gr = GlideRecord("<tablename>");

eg. var gr = GlideRecord("sys_user");
This is a malformed statement.

Resolution

It is necessary to utilize the "new" operator to create an instance of the GlideRecord before it can be used successfully from custom scripts.

 

Modify the statement to utilize the new operator:

var gr = new GlideRecord("<tablename>");

eg. var gr = new GlideRecord("sys_user");

 

Additional Information

For more information please see the following links.

 

New operator:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new

 

GlideRecord:

https://docs.servicenow.com/bundle/madrid-application-development/page/app-store/dev_portal/API_reference/GlideRecordClientSide/concept/c_GlideRecordClientSideAPI.html

 

 

Article Information

Last Updated:2019-05-21 11:58:17
Published:2019-05-09