The CreatorCon Call for Content is officially open! Get started here.

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

Hi @Hiteish222 

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

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

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
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

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

View solution in original post

NishantDhole
Mega Guru

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

Hi @Hiteish222 

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

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

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
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

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

NishantDhole
Mega Guru

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