We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

output is not displaying on Background script

neelamallik
Tera Contributor
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('workflow_state', 'draft');
gr.query();
while (gr.next()) {
    gr.deleteRecord();
}
 
neelamallik_0-1768728477277.png

 

3 REPLIES 3

miftikhar20
Kilo Patron

Hi @neelamallik,
You can add gs.info(gr.getRowCount()); after the query() to check whether any records match your criteria. If the count is 0, there are no draft records to delete, which is why you’re not seeing any output.
If my response helped, please mark it as the accepted solution so others can benefit as well.   

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

AmolJ
Tera Expert

I am having the same issue in last two days. There is something wrong with the SN Tools extension. I have checked the sys_id in my code and it is correct.

 

AmolJ_0-1771019462963.png

 

You can write gs.print(gs.display_name) 

And check it is working or not