- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2012 08:51 AM
I am trying to figure out how to hide some of my status items on a request item until all related tasks are closed. I reied simply hiding the options but then my Request Items would not auto close when the tasks closed.
Below is my fumbling attempt:
// Hide "Closed" Incident state from everyone but itil_admin function onLoad() { var optsk = new GlideRecord('task'); optsk .addQuery('request_item','number'); optsk .addQuery('state', optsk.state<4); optsk .query(); while (optsk .next()) { g_form.removeOption('state', 4); g_form.removeOption('state', 7); g_form.removeOption('state', 10); g_form.removeOption('state', 11); } }
The basic premise is that we don't want folk to close request items manually. We have a rule that closes them automatically when the tasks are all closed. My perfect world would be a simple rule that prevents closing a request item if there are any open tasks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2014 03:43 AM
Here is what we did for our Problem table to prevent problem closure if there were any active tasks. We created a business rule with the following conditions:
- Source Table = Problem
- Order = 10
- Active = Checked
- When = Before
- Insert and Update = checked
- Condition =
current.state == 7
- Script = =
//Query for associated active tasks
//Should be run as a 'before' business rule on the change_request table
var rec = new GlideRecord('problem_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('All Problem Tasks must be closed prior to closing the Problem');
current.setAbortAction(true);
}
Hope this helps you
~Conan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2014 03:43 AM
Here is what we did for our Problem table to prevent problem closure if there were any active tasks. We created a business rule with the following conditions:
- Source Table = Problem
- Order = 10
- Active = Checked
- When = Before
- Insert and Update = checked
- Condition =
current.state == 7
- Script = =
//Query for associated active tasks
//Should be run as a 'before' business rule on the change_request table
var rec = new GlideRecord('problem_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('All Problem Tasks must be closed prior to closing the Problem');
current.setAbortAction(true);
}
Hope this helps you
~Conan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2014 07:24 AM
Thank you Conan.
This worked brilliantly.
Shoaib
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2014 07:44 AM
Awesome, glad to hear it.
Go me, I actually helped someone instead of always asking for help. Woohoo!