We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. 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
Topmate: https://topmate.io/dratulgrover [ 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

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
Topmate: https://topmate.io/dratulgrover [ 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')));
 
}