I have a requirement to create SLA records for closed RITM's that never had an SLA at the time of closure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2022 03:03 PM
I have a bunch of RITMs that were created and closed before we had RITM SLA's implemented. Is there a script that would go through each, generating the SLA record?
Here's a script i had partly put together from a similar reply here
var gr = new GlideRecord('sc_req_item');
var strQuery = 'active=false';
strQuery = strQuery + '^item=<item name>'; //catalog item name
gr.addEncodedQuery(strQuery);
gr.query();
while (gr.next()) {
var created = gr.sys_created_on;
var actual_end = gr.work_end;
var grSLA = new GlideRecord('task_sla');
grSLA.newRecord();
grSLA.task = gr.getUniqueValue();
grSLA.sla = '<sys_id>'; //sys ID of the SLA i'd like to run here
grSLA.schedule = '<sys_id>'; //sys ID of the schedule i'd like to run here
grSLA.start_time = created;
grSLA.end_time = actual_end;
grSLA.insert();
var task_sla = new GlideRecord('task_sla');
task_sla.get(grSLA.getUniqueValue());
SLACalculatorNG.calculateSLA(task_sla, false, task_sla.end_time);
}
- Labels:
-
Service Level Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2022 11:08 PM
var gr = new GlideRecord('sc_req_item');
var strQuery = 'active=false';
strQuery = strQuery + '^item=<item name>'; //catalog item name
gr.addEncodedQuery(strQuery);
gr.query();
while (gr.next()) {
var created = gr.sys_created_on;
var actual_end = gr.work_end;
var grSLA = new GlideRecord('task_sla');
grSLA.newRecord();
grSLA.task = gr.getUniqueValue();
grSLA.sla = '<sys_id>'; //sys ID of the SLA i'd like to run here
grSLA.schedule = '<sys_id>'; //sys ID of the schedule i'd like to run here
grSLA.start_time = created;
grSLA.end_time = actual_end;
var newSlaRecord = grSLA.insert();
new SLACalculatorNG().calculateSLA(newSlaRecord, false, task_sla.end_time);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 06:15 AM
I get this output, it doesn't seem to run quite correctly. It looks like task_sla is no longer defined in your code example. Do we need to take that out?
[0:00:00.020] Compacting large row block (file.write: sc_req_item 10000 rows 160000 saveSize)
[0:00:00.017] Compacting large row block (file.write: sc_req_item 10000 rows 160000 saveSize)
[0:00:00.018] Compacting large row block (file.write: sc_req_item 10000 rows 160000 saveSize)
[0:00:00.021] Compacting large row block (file.write: sc_req_item 10000 rows 160000 saveSize)
[0:00:00.016] Compacting large row block (file.write: sc_req_item 10000 rows 160000 saveSize)
[0:00:00.016] Compacting large row block (file.write: sc_req_item 10000 rows 160000 saveSize)
[0:00:00.016] Compacting large row block (file.write: sc_req_item 10000 rows 160000 saveSize)
[0:00:00.016] Compacting large row block (file.write: sc_req_item 10000 rows 160000 saveSize)
[0:00:00.017] Compacting large row block (file.write: sc_req_item 10000 rows 160000 saveSize)
[0:00:00.240] id: ochsnerdev_1[glide.17 (connpid=84854)] for: DBQuery#loadResultSet[sc_req_item: active=falseitem=Access Request for Existing Application]
[0:00:00.011] Compacting large row block (file.write: sc_req_item 6170 rows 98720 saveSize)
[0:00:00.003] Expanding large row block (file.read: sc_req_item, 10000 rows, 160000 dataSize)
Evaluator: com.glide.script.RhinoEcmaError: "task_sla" is not defined.
script : Line(20) column(0)
17: grSLA.end_time = actual_end;
18: var newSlaRecord = grSLA.insert();
19:
==> 20: new SLACalculatorNG().calculateSLA(newSlaRecord, false, task_sla.end_time);
21: }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 09:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 09:54 AM
Not that i can see no