OOB rules to close request, item and task?

Allison3
Kilo Guru

Does anyone know what the Out of the Box rules are that close an item and request once a task is closed? I found the task closer business rule but this is on the request level.

I'm needing to add a new closed state to tasks. When this closed state is chosen I want it to close the item and request. I'm just having a hard time finding exactly what rule closes this out of the box to alter.

6 REPLIES 6

BJ Strohl
Kilo Explorer

I have the described business rule "Close Parent if Required" but none of my requests are closing whan the tasks are all resolved and the RITM is set to closed.

 

here is the scripting from that rule. Does anyone see the problem?

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', '!=', 'closed_skipped');
gr.addQuery('stage', '!=', 'closed_incomplete');
gr.addQuery('stage', '!=', 'Request Cancelled');
gr.query();
if (!gr.next()) {
// no peer task is currently open
gr.initialize();
gr.addQuery('request', current.request);
gr.query();
var ritmCount = gr.getRowCount();
var stage = 'closed_complete';
var incomplete = 0;
var skipped = 0;
while (gr.next()) {
if (gr.getValue('stage') == 'closed_incomplete' || gr.getValue('stage') == 'Request Cancelled') {
stage = gr.getValue('stage');
incomplete++;
break;
} else if (gr.getValue('stage') == 'closed_skipped') {
skipped++;
}
}
var sc_request = new GlideRecord('sc_request');
sc_request.addQuery('sys_id', current.request);
sc_request.query();
sc_request.next();
gs.debug("SC_REQUEST.STAGE = " + sc_request.stage + " INDEX = " + sc_request.stage.toString().indexOf('closed'));
if (sc_request.stage.toString().indexOf('closed') == -1) {
if (incomplete)
stage = 'closed_incomplete';
if (skipped == ritmCount)
stage = 'closed_skipped';
sc_request.stage = stage;
sc_request.comments.setJournalEntry("Request Automatically Closed as all Line Items were complete");
sc_request.update();
}
}
}

@BJ Strohl Iam facing the same issue.  the RITM's were closed but requests are still open.  how to achieve this?