after all iterations, needs to update RITM closed complete

venkata2023
Tera Contributor

venkata2023_0-1756138766003.png

There are 1 to 15 iteration/subflow calling, after this subflow calling want to update RITM close complete, as per present set up its updating prematurely, that means without completing all iterations its updating closed complete

4 REPLIES 4

Rafael Batistot
Kilo Patron

Hi @venkata2023 

May you consider create a Business rule after > updated in your sc_task table,  advance = true 

Code: 

if (current.state != '3') // 3 = Closed Complete (adjust if different)
        return;

    var taskGR = new GlideRecord('sc_task');
    taskGR.addQuery('request_item', ritm);
    taskGR.addQuery('state', '!=', '3'); // still open tasks
    taskGR.query();

    if (!taskGR.hasNext()) {
        // All tasks are closed → close the RITM
        var ritmGR = new GlideRecord('sc_req_item');
        if (ritmGR.get(ritm)) {
            ritmGR.state = '3'; // Closed Complete
            ritmGR.update();
        }
    }
If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.

There are no tasks on the flow, its adding user to the groups

Ankur Bawiskar
Tera Patron
Tera Patron

@venkata2023 

please move the logic of closing RITM in your main flow or using after update business rule on sc_task table

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi ankur, thank you for your reply, there are no tasks in this flow, i am calling subflow for each list collector value, after completing for each loop, i want to update RITM close complete