Prevent PRB closure when active children
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2015 11:00 AM
My goal is to prevent Problem tickets from closing when there are active Problem Tasks OR Change Requests. I have the business rule below and it is aborting the submission, but it aborts even if all children are closed.
I also tried changing rec.addQuery('problem', current.sys_id); to rec.addQuery('parent', current.sys_id); but that only prevented closure on Change Requests and not Problem Tasks...which really didn't make sense.
Business Rule:
Table: Problem
Condition: current.problem_state == 4 This is closed.
When: Before --> Update
//Query for associated active tasks
//Should be run as a 'before' business rule on the planned_task table
var rec = new GlideRecord('task');
rec.addQuery('problem', current.sys_id);
rec.addQuery('active', true);
rec.query();
//If any of the tasks are active abort the submission
if(rec.hasNext()){
gs.addInfoMessage('Submission aborted due to active child tasks.');
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2015 01:08 PM
That business rule will run on any task that is being de-activated (i.e. active is true and changing to false).
If you put this BR (business rule) on the Problem table, this business rule will only run when Problem records are de-activated, but the scope of the GlideRecord query still looks for any task that is parent to the Problem record being updated.
To answer your question, even if I had a Requested Item or an Incident that was parent to the Problem record (parent field of the Requested Item or Incident is set to the Problem record), this problem will not be able to close.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2015 01:18 PM
Thank you! I will review and update this article with the results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2015 10:54 AM
Daniel,
I could not get the script to work. The route that I took is to use two business rules on the Problem table like below; one for Problem Tasks and one for Change Requests.
//Query for associated active tasks
//Should be run as a 'before' business rule on the planned_task table
var chg = new GlideRecord('change_request');
chg.addQuery('parent', current.sys_id);
chg.addQuery('active', true);
chg.query();
//If any of the tasks are active abort the submission
if(chg.hasNext()){
gs.addInfoMessage('Submission aborted due to active child Change Request tasks.');
current.setAbortAction(true);
}
Thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2015 11:23 AM
If you are trying to limit the closure of the Problem, you will have to put those 2 business rules on the Problem Table instead of the planned_task table.
If you are originating from a change request that is linked to a Problem (through the parent field), then you Glide Query actually changes as well.
current becomes the Change Request, and the parent field for the Change Request will have the Problem record.
Problem Tasks are the same way, and I understand that Problem Tasks are not out of box, so your table name must be something like u_problem_task...?
current for this business rule becomes the Problem Task, and the parent field for the Problem Task will have the value of the Problem record.
Keep in mind that Problems are not extended from the Planned Task table, but only the Task table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2015 11:58 AM
Daniel,
Thank you for the additional information. I am using the Problem table for both business rules. The Task table didn't work as I hoped. Planned Task wasn't one that I tried. Problem Tasks are out of the box; table is problem_tasks. Although it is not in 1 business rule like I wanted, I am OK with the current design. Thank you very much for your help.