GlideQuery.parse does not function in server - scoped environments.

Sean Mauk
Tera Expert

Running the below codes results in an error that reads: "TypeError: Cannot find function parse in object GlideQuery<undefined> []."

 

var table = 'incident'
var equery = "";
var gq = new global.GlideQuery()
  .parse(table,equery)
  .select('number')
  .forEach(
    function(u){
      gs.info(u.number)
  });

 

I have tried a number of variations like this: 

 

var table = 'incident'
var equery = "";
var gq = new global.GlideQuery(table)
  .parse('incident',"")
  .select('number')
  .forEach(
    function(u){
      gs.info(u.number)
  });

 

None of which work in a scoped application from do work if I am globally scoped. It appears as if the parse function is not included in the Server Scoped variant of GlideQuery even though the documentation specifically says that it is. Any help would be much appreciated.

1 ACCEPTED SOLUTION

Assuming you have a cross scope privilege to call GlideQuery, this is the correct syntax.

 

var table = "incident";
var equery = "numberENDSWITH111";
global.GlideQuery.parse(table, equery)
  .select("number")
  .forEach(function (inc) {
    gs.info(inc.number);
  });

 

parse() is a static class method not a class instance method.

View solution in original post

3 REPLIES 3

varaprasad123
Kilo Guru

I think issue is with Empty Query String, Can pass something like below and try?

 

var table = 'incident';
var equery = 'state=2'; // Use the appropriate condition for 'Active' state
var gq = new global.GlideQuery()
  .parse(table, equery)
  .select('number')
  .forEach(function(u) {
    gs.info(u.number);
  });

 

Running the code you posted results in the same error "Cannot find function parse in object GlideQuery...".

Assuming you have a cross scope privilege to call GlideQuery, this is the correct syntax.

 

var table = "incident";
var equery = "numberENDSWITH111";
global.GlideQuery.parse(table, equery)
  .select("number")
  .forEach(function (inc) {
    gs.info(inc.number);
  });

 

parse() is a static class method not a class instance method.