When REQ is submitted automatically RITM is closing
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 01:15 AM
Hi,
When I have submitted REQ, RITM is creating, under RITM Tasks generated.
But when REQ is submitted automatically RITM is going to a closed complete state, But all the Tasks are in the open state only.
When Tasks are closed then only RITM and REQ should be closed.
Please help me
Thanks
Sriram
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 02:57 AM
Hi sriram,
You should have a business rule on Requested item table, which can trigger the closure.
Below is an example.
closeParentIfRequired();
function closeParentIfRequired(){
// check to see if any of our peers are currently *not* closed
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.request);
gr.addQuery('stage', '!=', 'complete');
gr.addQuery('stage', '!=', 'Request Cancelled');
gr.query();
if (!gr.next()) {
// no peer task is currently open
var sc_request = new GlideRecord('sc_request');
sc_request.addQuery('sys_id', current.request);
sc_request.query();
sc_request.next();
gs.print("SC_REQUEST.STAGE = " + sc_request.stage + " INDEX = " + sc_request.stage.toString().indexOf('closed'));
if (sc_request.stage.toString().indexOf('closed') == -1) {
sc_request.stage = "closed_complete";
sc_request.comments.setJournalEntry("Request Automatically Closed as all Line Items were complete");
sc_request.update();
}
}
}