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 - LNG
Tera Patron

Hi @Hiteish222 

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

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 - LNG
Tera Patron

Hi @Hiteish222 

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

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')));
 
}