How to Auto Close Incomplete a Request if a Catalog Task is Closed Incomplete

terrieb
Tera Guru

Back in Workflows, you could add conditions to all tasks of Closed Incomplete or Closed Complete state.  If the task was Closed Incomplete, then the Request/RITM would go to Closed Incomplete state.  If the task was Closed Complete, then it would move to the next task in the flow.  This was very useful if there were multiple tasks in a workflow, especially when using the Branch/Join function.

 

However, in the new Flow Design, the only option you have is the "Wait for" condition to put in that option.  And then you have to include an "If" action if the state is Closed Incomplete to make the state of the Request/RITM Closed Incomplete.

 

This is very cumbersome, especially if there are multiple tasks and it could be a task that is NOT the last task, that is marked Closed Incomplete, so now the admin has to go and either Cancel the Request to close both Request/RITM or manually change the state on both tables.

 

If there a way we can do this without the Flow Activities?  I have tried a BR and UI Policy but they don't work.

 

Thanks!

7 REPLIES 7

Viraj Hudlikar
Giga Sage

Hello @terrieb 

Writing after BR on sc_task when state changes to close incomplete, then in script section put a code logic which will update state = Close Incomplete and stage = Request Cancelled for related RITM by query if its active or already closed incomplete. Once this is done other related sc_task will get auto cancel by OOTB BR "Close Tasks Due to Cancellations".

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.


Thanks & Regards
Viraj Hudlikar.

Can you send me a sample script for this which I assume will be on the catalog task table?  I tried a few and none have worked so far...

 

Thanks

Awaiting a sample script to use?

 

Thank you

Hello @terrieb 

 

Apologies for delay. Sample script can be as below: 

// Check if the state has changed to Closed Incomplete
    if (current.state == 'Closed Incomplete') {
        var ritm = new GlideRecord('sc_req_item');
        if (ritm.get(current.request_item)) {
            // Update the RITM state and stage if it's active or already closed incomplete
            if (ritm.state != 'Closed Incomplete' && ritm.state != 'Closed Complete') {
                ritm.state = 'Closed Incomplete';
                ritm.stage = 'Request Cancelled';
                ritm.update();
            }
        }
    }


If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.