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.

Display Incident Count with Child Incident Numbers using Display Business Rule

abhisnow020
Tera Contributor
 
2 REPLIES 2

Swapna Abburi
Mega Sage
Mega Sage

Hi @abhisnow020 

 

You can write below script in Display business rule.

 

var agg = new GlideAggregate('incident');
agg.addQuery('parent_incident', current.sys_id);
agg.addAggregate('COUNT');
agg.query();
if (agg.next()) {
 g_scratchpad.childIncCount = agg.getAggregate('COUNT');
}

Sandeep Rajput
Tera Patron
Tera Patron

@abhisnow020 Here is the BR.

 

Screenshot 2025-02-24 at 8.40.29 PM.pngScreenshot 2025-02-24 at 8.40.04 PM.png

 

Script.

 

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var grChild = new GlideAggregate('incident');
    grChild.addQuery('parent', current.sys_id);
	grChild.addAggregate('COUNT');
    grChild.query();
	if (grChild.next()); {
		gs.addInfoMessage('Number of child incidents ' + grChild.getAggregate('COUNT'));	
	}	

})(current, previous);