Request closing when first RITM closes rather than waiting for all RITM's to be completed

steveturley
Tera Guru

Just testing the 'add to cart' functionality on an instance that hasn't utilised it before.

 

For some reason, if there is multiple RITM's the parent REQ is being closed when the first RITM moves to 'closed complete' rather than waiting for all RITM's to be completed.

 

Anyone know why this would be happening and, more importantly, how can I stop it doing it?

 

Thanks!

4 REPLIES 4

krishi2003
ServiceNow Employee
ServiceNow Employee

Got a similar case. Have you solved this issue?

 

Simran Gadodiya
Mega Sage

@steveturley 
You can check OOB Business rules that is closing the request or else you can create Business rule to wait it till all RITM will be close complete or you can edit flow for the same.

If it helps you mark it as helpful.

Thanks.

vishalAg20
Tera Contributor

Hi All,
did you create any BR for that Is it work ? same Issue I am also facing. 

tripu
Tera Expert

Hello @steveturley , @vishalAg20 , @krishi2003 , @Simran Gadodiya

Below is my solution.

I created a Business Rule to overcome the issue.

The Business Rule is created on 'sc_req_item' table.
When to run --> After - Update

Conditions --> State is Closed Complete

Script:

    var req = current.getValue('request');
    var grReqItem = new GlideRecord('sc_req_item');
    grReqItem.addEncodedQuery('stateNOT IN3,4,7^request=' + req);
    grReqItem.query();
    while (!grReqItem.next()) {
        var grReq = new GlideRecord('sc_request');
        grReq.addQuery('sys_id', req);
        grReq.query();
        if (grReq.next()) {
            grReq.request_state = 'closed_complete';
            grReq.stage = 'closed_complete';
            grReq.state = 3; // Closed Complete
            grReq.update();
        }
    }