We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to get the count of SLA attached to particular incident

Hiteish222
Kilo Guru

Hi,

please find below interview use case :

 

How to get the count of SLA attached to particular incident ?

2 ACCEPTED SOLUTIONS

Dr Atul G- LNG
Tera Patron

Hi @Hiteish222 

 You can get via report , where you need to enter the specific incident number in condition. 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG

****************************************************************************************************************

View solution in original post

Not applicable

Hi @Hiteish222,

  Please find the below script for the solution of above scenario:

//get sys_id of the incident
var incidentSysId = 'ed92e8d173d023002728660c4cf6a7bc';
 
var slaCount = new GlideAggregate('task_sla');
slaCount.addQuery('task', incidentSysId); 
slaCount.addAggregate('COUNT');
slaCount.query();
 
if (slaCount.next()) {
    gs.info('Number of SLAs attached to the incident: ' + parseInt(slaCount.getAggregate('COUNT')));
 
}

View solution in original post

2 REPLIES 2

Dr Atul G- LNG
Tera Patron

Hi @Hiteish222 

 You can get via report , where you need to enter the specific incident number in condition. 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG

****************************************************************************************************************

Not applicable

Hi @Hiteish222,

  Please find the below script for the solution of above scenario:

//get sys_id of the incident
var incidentSysId = 'ed92e8d173d023002728660c4cf6a7bc';
 
var slaCount = new GlideAggregate('task_sla');
slaCount.addQuery('task', incidentSysId); 
slaCount.addAggregate('COUNT');
slaCount.query();
 
if (slaCount.next()) {
    gs.info('Number of SLAs attached to the incident: ' + parseInt(slaCount.getAggregate('COUNT')));
 
}