Emails on Request Table with Multiple RITMS

terrieb
Tera Guru

So we are pushing the "Cart" option on the employee portal which creates multiple RITMS, which is all good.

 

The issue we are having that as soon as the first RITM is closed complete, the Request goes to Closed Complete state and it sends out the Request Complete emails to ALL the RITM requested for, even if the other RITMS are still Open.

 

Is there a way to fix this behavior so it doesn't send out the Request is Completed until ALL the RITMS linked to it are closed?

 

Thanks!

9 REPLIES 9

Tanushree Maiti
Tera Patron

Hi @terrieb 

 

1. Check  OOB BR "Close Parent if required" on sc_req_item whether it is customized

or

if you have any customized BR where using script , you are closing sc_request record.

 

2. Confirm "Mark request closed" OOB BR on sc_request having highest order and not customized.

3. If you are using Flow Designer, ensure that the flow only closes the Request after all RITMs have completed their sub-flows

 

It seems you have some script (in BR) which is closing sc_request record without checking whether all RITM have been closed. check it.

 

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

I checked both BR's and there is no customization to either one.    I am attaching screen shots of both.  There doesn't appear to be anything in the extensive script on the Request table that addresses the state of the requested items linked.  

 

There are no client scripts either

 

Thanks!

pr8172510
Tera Guru

Hey @terrieb,

 

Create This Business Rule on sc_req_item

Table: Requested Item [sc_req_item]
When: Before
Update: 
Order: 1 (very important - lower than OOB rules)
Condition: current.state == 'closed_complete' && current.request.state != 'closed_complete'

(function executeRule(current, previous) {

var request = current.request;

if (!request) {
return;
}

// Count how many RITMs are still open (not closed)
var openRITM = new GlideRecord('sc_req_item');
openRITM.addQuery('request', request);
openRITM.addQuery('state', 'NOT IN', 'closed_complete,closed_incomplete,cancelled');
openRITM.addQuery('sys_id', '!=', current.sys_id); // Exclude current RITM
openRITM.setLimit(1);
openRITM.query();

if (openRITM.hasNext()) {
// There are other open RITMs - prevent the parent Request from closing
gs.eventQueue('sc_request.reopen', request, request.sys_id, null);

gs.addInfoMessage('Request #' + request.number + ' remains open. Waiting for other requested items to complete.');
}

})(current, previous);

Nope didn't work.

 

I turned inactive the OOB Requested Item BR and created this one.

 

Then I "ordered" 2 items using the Cart methodology, so it created 1 request and 2 Ritms.  

However, when I closed the 1st RITM, it closed the Request

Looked at History of the request (see below)

 

terrieb_0-1778855177591.png

 

Or should I have left active the existing RITM OOB BR?