The CreatorCon Call for Content is officially open! Get started here.

GlideRecord is undefined in Script Include

jbrooks
Mega Contributor

Hi! I'm on Fuji, trying to access data from a custom table to use in a scheduled job, and I keep getting the following in my system log:

org.mozilla.javascript.EcmaError: "user_credentials" is not defined.

Caused by error in <refname> at line 6

3: function pollNetScaler() {

4: gs.log('Start poll');

5: var user_credentials = new GlideRecord('u_custom_credentials');

==> 6: user_credentials.query();

I replaced my custom table with a vanilla system table- sys_user- but got the same result. I'm running the scheduled job a myself (and I have the admin role). What might I be missing here? How can I access table data?

1 ACCEPTED SOLUTION

I do see them, yes! And that line gives me the object type of netscale_use- which I see was from a previous iteration of this script, and I see that I DID make a typo in my variables previously, which leads to this. Auuugh! I'm a fool.



Thanks, everyone, for your responses! It helped me look at this in a bunch of different, helpful ways.


View solution in original post

11 REPLIES 11

Ken83
Mega Guru

Maybe try using a different variable name like userCredentials


jbrooks
Mega Contributor

user_credentials is actually an example name; I used a different name in the actual script, and it did not work. This does not appear to be a namespace collision for that name.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi John,



Can you please paste the completed script here so that we can debug further.


pollRestDevice();



function pollRestDevice() {


  gs.log('Start poll','BROOKS');


  var user_credentials = new GlideRecord('u_custom_credentials');


  user_credentials.query(); // <-- script errors out here.


  user_credentials.next();


  gs.log("made a gliderecord, type " + typeof netscale_user,"BROOKS");


  var query = new restDeviceQuery(); <-- this is a script include that runs without issue.


  gs.log("Begin query","BROOKS");


  query.queryAppliance();


}



This is my script!