Receiving error messageGlideAjax not defined

Jeff96
Tera Contributor

I'm having an issue calling script include from a UI Action.  I thought I would test a simple script from Background Script that returns department name from sys_user table record.  Below is the client script I'm running from Background Script and the script include which is set to 'Client callable'.  Both actions are in Global scope.  Whenever I run the script I receive an error indicating 'GlideAjax' is not defined.  It use to be that when typing the declaration line (var ga = new GlideAjax('script_include_name'), the  whole GlideAjax declaration would turn italic after completing the command.  This is not the case now.  The script include name turns italic but GlideAjax does not (var ga = new GlideAjax('script_include_name').  I can confirm that 'AbstractAjaxProcessor' is in the system.

 

Any help is greatly appreciated.

 

Jeff96_1-1695050737947.png

 

 

Jeff96_4-1695050839581.png

 

7 REPLIES 7

Danish Bhairag2
Tera Sage
Tera Sage

Hello @Jeff96 ,

 

U cannot execute client script code in Background Script as Background script is a Server side Script.

 

Read more about it here:

https://docs.servicenow.com/en-US/bundle/vancouver-application-development/page/script/server-script...

 

Please mark my response helpful if it resolves your issue.

 

Thanks,

Danish

KevinBellardine
Kilo Sage

You're gonna hate it if this is the right answer, but from what you posted it looks like your SI definition user a lowercase U and your script is calling it using an uppercase U.

Hi Tera Expert,

Sorry, I've best working on this for a while and copied the wrong script. It doesn't work with lowercase u in script include name as well (var ga = new GlideAjax('g_userDepartmentDetail');.  I thought that was my issue as well.

Hi @Jeff96 ,

 

You can test ur script include from background script by calling it this way.

 

var execOutput = new g_userDepartmentDetail().details(Id);// enter hard-coded sys I'd in string