- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 07:25 AM
Hello,
I am trying to create a Business Rule so that when an Incident Task state changes to "Closed complete", the parent's owner is informed of this closure through the work notes.
Below is the Business Rule I created, however it is not working and I can't seem to find a correct script to make it work:
The script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.parent.work_notes="The Incident Task " + current.number + " has been completed.";
/*var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.parent);
gr.query();
gr.work_notes="The Incident Task " + current.number + " has been completed.";*/
})(current, previous);
Any idea of how I could make this BR work?
Thank you in advance!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2020 05:38 AM
Manon,
Can you try the below code, it should work for sure
var parent = current.parent;
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',parent); //gr.addQuery('sys_id',parent.toString());
gr.query();
if(gr.next()){
gr.work_notes="The Incident Task " + current.number + " has been completed.";
gr.update();
}
Please mark as correct if this helps!!!
-Vinay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 07:30 AM
I notice in the code that you commented out, you are missing the gr.update();
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.parent);
gr.query();
gr.work_notes="The Incident Task " + current.number + " has been completed.";
gr.update();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 07:44 AM
Thank you for your quick answer, but it is still not working 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 08:11 AM
Out of the box parent is not used. On the incident task form, 'incident' is the correct name of the field.
Change this:
gr.addQuery('sys_id',current.parent);
To this:
gr.addQuery('sys_id',current.incident);
Also, update the condition of the Business rule to use the incident field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2020 12:50 AM
I see what you mean, but we don't use the original incident task form. We created a table u_incident_task where all tasks are recorded, and the name of field linking to the parent incident on the form is 'parent'.
I'll still try your solution just in case.