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.

Show the number of Child tasks of Parent task?

Ramya49
Tera Contributor

How to Create Script to show the number of child tasks of Parent task ?

Expected output : Number of Incidents : 23

Please anyone help me with this

 

3 REPLIES 3

kunal20
Kilo Guru

Hi Rams,

you can use the following code:-

var count=0;
var gr=new GlideRecord('incident');
gr.addQuery('sys_id','sys_idOfIncident');
gr.query();
if(gr.next()){
    var gre=new GlideRecord('incident');
    gre.addQuery('parent_incident','sys_idOfIncident');
    gre.query();
    while(gre.next()){
        count++;
    }
}
gs.log(count);

Ramya49
Tera Contributor

Hi Kunal,

Where can I execute this code . Can I write an email script or any other option ?

Community Alums
Not applicable

How is this looks Email script to you? is your question related to Email by any chance?

Please share what you have done till now