- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2020 01:13 AM
Hi All,
I need to get the data from breach time(planned end date) field in task_sla table and get it displayed in custom field in incident table form.I have tried many business rules by taking reference from community only but i cant able to get it.Can anyone help me giving the exact script required for it.Lets take the custom field as Date,Time(u_date_time).
Thanks,
Arjun.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2020 12:40 AM
Hello Arjun,
You need to write before insert & update business rule on task_sla table. Also add condition as SLA definition changes in condition builder.
if (current.task.sys_class_name == 'incident') {
var gr = new GlideRecord('incident');
if (gr.get(current.task.sys_id)) {
gr.u_breach_date_time = current.planned_end_time; // it will set the breach date-time in custom field of type date/time on incident form.
gr.update();
}
}
It will gives you current SLA planned end time.
Hope this will help you.
Regards,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2020 01:35 AM
You could write an after update business rule on the task_sla table and set it to trigger when the sla definition is '<your sla definition>' and has breached changes to true. The script just needs to glide into the parent incident record and set the u_date_time field to your breach time.
var gr = new GlideRecord('incident');
if(gr.get(current.task)){
gr.u_date_time = current.planned_end_time;
gr.update();
}
EDIT: obviously change the conditions if you want the breach time to be added at another time. If you want it to be added right away just change the rule to be after insert and remove the has breached condition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2020 01:39 AM
Hello Arjun,
You need to Before update business rule on task_sla table.
here is the script.
if (current.task.sys_class_name == 'incident') {
var gr = new GlideRecord('incident');
if (gr.get(current.task.sys_id)) {
// gr.u_resolution_percentage = parseInt(current.percentage); // it copies business elapsed time and converted in to % percentage in to custom field
gr.u_date_time = current.planned_end_time; // it copies breach date- time to custom field
gr.update();
}
}
Regards,
Sagar PAgar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2020 01:41 AM
Hi Arjun
Just be careful as there used to be a 1:1 relationship historically with task and sla and there used to be a "has breached" field and an "SLA percentage" field on the task tables that has been deprecated over the years.
One of the reasons this was done was that a task can have multiple sla's associated with it now. So just be careful about what you are copying over
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2020 05:12 AM
Hi Sagar,
Thanks for your reply's.I have used it in my personal instance,by using that script you have provided i am getting the breach time of the previous priority ie., if i updated my priority to 1 which is 2 at starting it is still giving the breach time of 1(previous priority breach time).
can you help me in this.
Thanks,
Arjun.