I want to find total no. of incidents which are having problem record and print those INC numbers.

Parth_S
Tera Contributor

Please have a look on my script -

 

var gr = new GlideRecord('incident');
gr.addEncodedQuery('problem_idISNOTEMPTY');
gr.query();
gs.print('found');
while(gr.next()){
    gs.print('INC are: ' + gr.number);
}
 
I don't know but I am not able to see any O/P in script background.
 
So pls can anyone correct me where did i made mistake and suggest me correct script.
7 REPLIES 7

Anand Kumar P
Giga Patron
Giga Patron

Hi @Parth_S ,

 

 

 

var gr = new GlideRecord('incident');
gr.addEncodedQuery('problem_id!=NULL');
gr.query();
gs.print('found');
while(gr.next()){
    gs.print('INC are: ' + gr.number);
}

 

 

Above script working fine for me. You dont have problem record attached to incident.In  List view add problem record to problem column for incident record it will show output.

 

IMG_6796.jpeg

IMG_6795.jpeg

 

If my response helped, please mark it as the accepted solution and give a thumbs up👍.
Thanks,
Anand 

Hii @Anand Kumar P

After adding filter that Problem -> is not empty, i am able to see 23 records in list view.

And to all those incidents, problem record is attached.

Still you are not able to see the records in Background script?

Above screenshots you can see which i attached working as expected.

 

AndersBGS
Tera Patron
Tera Patron

Hi @Parth_S ,

 

what is the business requirement since you’re scripting?

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up. 

best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/