Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

GlideRecord issue using addNotNullQuery

ServiceNow Use6
Tera Guru

Hi,

I am working on GlideRecord method addNotNullQuery() and I am facing the issue. I believe I am getting wrong output. Kindly help.

var gr = new GlideRecord("incident");
var shortDesc = gr.addNotNullQuery('short_description');
gr.query();
while(gr.next()){
gs.addInfoMessage("The short description for " + gr.number + " is " + shortDesc);
}

 

find_real_file.png

 

Regards

Suman P.

1 ACCEPTED SOLUTION

Srikanth_Peru
Tera Guru

Hi @ServiceNow User

Please use this Script :

var gr = new GlideRecord("incident");
gr.addNotNullQuery("short_description");
gr.query();
while(gr.next()){
gs.addInfoMessage("The Short Desription for: " +gr.number +" is "+gr.short_description);
}

 

 

Please mark my response Answered and Hit Helpful 

View solution in original post

3 REPLIES 3

Srikanth_Peru
Tera Guru

Hi @ServiceNow User

Please use this Script :

var gr = new GlideRecord("incident");
gr.addNotNullQuery("short_description");
gr.query();
while(gr.next()){
gs.addInfoMessage("The Short Desription for: " +gr.number +" is "+gr.short_description);
}

 

 

Please mark my response Answered and Hit Helpful 

Hemant Goldar
Mega Sage

Hello,

 

addNotNullQuery()- filter that specifies records where the value of the field passed in the parameter is not null.

You may find the below link helpful.

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/no-namespace/c_GlideRecordSco...

var gr = new GlideRecord("incident");
gr.addNotNullQuery('short_description');
gr.query();
while(gr.next()){
gs.addInfoMessage("The short description for " + gr.number + " is " + gr.short_description);
}

 

Thanks

Hemant

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

your script should be like this

var gr = new GlideRecord("incident");
gr.addNotNullQuery('short_description');
gr.query();
while(gr.next()){
	gs.addInfoMessage("The short description for " + gr.number + " is " + gr.short_description);
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader