- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2015 06:01 AM
Hi All, I have a business rule that copies the planned end time of a task sla into a field called SLA_due on the incident table. this is so I can have a field that shows the sla deadline based on colour. the problem I have is if the task sla planned end time changes because the priority has changed my field doesn't update with the new planned end time. could someone take a look at the script and point me in the right direction of what is missing?
var new_sla_due;
var gr = new GlideRecord("task_sla");
gr.addQuery("task", current.task);
gr.addQuery("stage", '!=', 'achieved');
gr.orderBy("planned_end_time");
gr.query();
if (gr.next())
{
new_sla_due = gr.planned_end_time;
}
if (new_sla_due)
{
var incidentRec = new GlideRecord('incident');
incidentRec.addQuery('sys_id', current.task);
incidentRec.query();
if(incidentRec.next())
{
incidentRec.sla_due = new_sla_due;
incidentRec.update();
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2015 01:58 AM
Set up the condition as in the screenshot. This is defined on task_sla table and 'before' insert and update operation.
//Script
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.task);
gr.query();
if(gr.next())
{
gr.sla_due = current.planned_end_time; //Make sure sla_due is the correct field name
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2015 08:16 AM
Nicky,
As a starting point, can you provide some more details about the business rule? Is it a before or after? Insert and Update of the incident table?
Thanks
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2015 01:30 AM
Hi Brian, sorry for the late reply. my rule is run after and on insert or update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2015 01:58 AM
Set up the condition as in the screenshot. This is defined on task_sla table and 'before' insert and update operation.
//Script
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.task);
gr.query();
if(gr.next())
{
gr.sla_due = current.planned_end_time; //Make sure sla_due is the correct field name
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2015 03:39 AM
thanks for your info that really helped fixing this for me as I was going a bit mad.