Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Display Incident Count with Child Incident Numbers using Display Business Rule

abhisnow020
Tera Contributor
 
2 REPLIES 2

Swapna Abburi
Giga 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

@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);