SLA applied at TASK- How to determine if RITM breached?

jlaps
Kilo Sage

Good afternoon community,

I have been tasked with determining if our new hire process is completing within SLA, in it's entirety. Right now, the REQ fires a RITM, which when approved, kicks out multiple TASKs. We have the SLA being applied to the TASKs correctly, and we can pull our reporting data fine at that level. The ask now however is, to check if the entire RITM was a breach or not- if one TASK breaches, the RITM is considered breached. We can say that 98% of New Hire TASKs are completed within SLA, but have trouble converting that to RITM level.

We do have a database view setup that we are using now to link task_sla, sc_task, and sc_req_item, so I think I have all the data gathered, but don't think I have the pieces to work with yet. I can get a list with all the TASKs showing breached or not, grouped under their corresponding RITM. The RITM has a "Has Breached" field, so I think I could script something to mark the parent as breached, but I was hoping I could figure out a way without another script.

I think I could create another SLA and apply it to the New Hire REQ at approval also, but it seems like I should be able to use what I have...

Thanks!

Jeff

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Jeff,



I guess Scripting is the only way to achieve it. All you need is a simple business rule written on task_sla table that runs when Has breached of task_sla changes to true.



Below before business rule on update   should help.



(function executeRule(current, previous /*null when async*/) {




// Add your code here


var nw=new GlideRecord('sc_task');


nw.addQuery('sys_id',current.task);


nw.query();


while(nw.next())


{


gs.log('In loop1');


var rw=new GlideRecord('sc_req_item');


rw.addQuery('sys_id',nw.request_item);


rw.query();


while(rw.next())


{


gs.log('In loop2');


rw.u_has_breached=true; //Considering u_has_breached is field dictonary name


rw.update();


}


nw.update();


}




})(current, previous);


View solution in original post

3 REPLIES 3

Jaspal Singh
Mega Patron
Mega Patron

Hi Jeff,



I guess Scripting is the only way to achieve it. All you need is a simple business rule written on task_sla table that runs when Has breached of task_sla changes to true.



Below before business rule on update   should help.



(function executeRule(current, previous /*null when async*/) {




// Add your code here


var nw=new GlideRecord('sc_task');


nw.addQuery('sys_id',current.task);


nw.query();


while(nw.next())


{


gs.log('In loop1');


var rw=new GlideRecord('sc_req_item');


rw.addQuery('sys_id',nw.request_item);


rw.query();


while(rw.next())


{


gs.log('In loop2');


rw.u_has_breached=true; //Considering u_has_breached is field dictonary name


rw.update();


}


nw.update();


}




})(current, previous);


Thank you Jaspal, I was thinking it may have to go that way.



This catches those that breach going forward, but in order to get this resolved historically, I would likely do a fix script yes?



Thanks again!


Jeff


Yes Jeff, you would require a background script to update those records at one go.