- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 02:25 PM
I have a record producer that creates a parent enhancement task and auto creates 5 child general task. I would like to prevent from 'Closed Complete' the parent task until all the child general task are 'Closed Complete'.
Can someone please help with this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 02:49 PM
You would need a BR something like below:
and your script will look similar to below:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('pass child table name');
gr.addQuery('parent', current.sys_id);
gr.addQuery('state', '!=', 3);
gr.query();
while(gr.next()){
gs.addErrorMessage('Cannot close Parent with open child');
current.setAbortAction(true); //abort the record
}
})(current, previous);
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 02:27 PM
You would need a business rule, query all the tasks state and abort submission.
https://www.servicenowelite.com/blog/2016/6/11/learn-business-rules
https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=c_GlideRecordScopedAPI
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 02:38 PM
Thank you. But i'll need some help with the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 02:49 PM
You would need a BR something like below:
and your script will look similar to below:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('pass child table name');
gr.addQuery('parent', current.sys_id);
gr.addQuery('state', '!=', 3);
gr.query();
while(gr.next()){
gs.addErrorMessage('Cannot close Parent with open child');
current.setAbortAction(true); //abort the record
}
})(current, previous);
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 02:55 PM
Thank you!