Emails on Request Table with Multiple RITMS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
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.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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)
Or should I have left active the existing RITM OOB BR?