How to modify business rules so they update the RITM and request states on rejection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 02:08 AM
I'm looking for some help as I'm not a scripter.
We have request workflows that when rejected by the approver they close the RITM and request with State/Request State Closed Complete. We'd like them to change state to Closed Rejected (a new choice we created) of Closed Incomplete which is present out of the box.
I've checked the business rules as these override using a set values activity I added to the workflows to change states. There are several business rules which look like they might be involved one is Close Parent if Required.
Looking at the script it looks as though the only setting applied to request stage is Closed Complete:
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();
}
}
}
There is also another BR called Mark Request Closed:
if (current.request_state == "closed_complete" ||
current.request_state == "closed_incomplete" ||
current.request_state == 'closed_cancelled' ||
current.request_state == 'closed_rejected' ||
current.stage == "closed_complete" ||
current.stage == "closed_incomplete") {
current.active = false;
if (current.closed_by.nil())
current.closed_by = gs.getUserID();
if (current.closed_at.nil()) {
current.closed_at = gs.nowDateTime();
current.business_duration = gs.calDateDiff(current.opened_at.getDisplayValue(),current.closed_at.getDisplayValue(),false);
current.calendar_stc = gs.dateDiff(current.opened_at.getDisplayValue(),current.closed_at.getDisplayValue(),true);
}
if(current.state == 1) {
var state = current.request_state.indexOf('closed') == 0 ? current.request_state : current.stage;
switch(state + '') {
case 'closed_complete':
current.state = 3;
break;
default:
current.state = 4;
break;
}
}
}
So what I'm looking for help on is how to ensure that when an approver has rejected a request/RITM that this is reflected in the state/request state of both the Request and RITM.
- Labels:
-
Request Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018 06:16 AM
This workflow runs on the sc_req_item table? What's in the Set values activity? Active=false, State is 8?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018 08:24 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018 01:16 PM
Ah... you can't set the Request since the update is happening on the RITM. And when you Closed Rejected the RITM, it Closed Complete the Request? (how it works out of box) Isn't that OK? Is this the only RITM on this Request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2018 03:17 AM
I removed the condition for the parent request. Would the closure state on the request then need to be one of the OOTB BRs which I mentioned?
Re-ran with just the state change to the RITM to closed rejected. It still closes as closed complete. This is the only RITM on the request.
The biggest issue is not being able to get the correct closure state for the RITM. The set value doesn't change the state. Could this be because the RITM is automatically marked as inactive by the output from the approval activity?