Close RITM after de last task

AugustoObramax
Tera Contributor

I would like to develop a flow for RITM, so that when the last task is completed, it automatically closes the RITM. How can I do that?

1 ACCEPTED SOLUTION

Karthiga S
Kilo Sage

Hi @AugustoObramax 

 

1. Navigate to Flow Designer in ServiceNow.

2. Click on "New" to create a new flow.

3. Set the trigger for the flow as "When record is updated" and select the table as "sc_task".

4. Set the condition for the trigger as "Task State changes to Closed Complete".

5. Add an action to "Look up Record" from the "Requested Item [sc_req_item]" table where "Requested Item is the parent of the Task".

6. Add a decision to check if "All child Tasks of the Requested Item are in Closed Complete state".

7. If true, add an action to "Update Record" and set the "State of the Requested Item to Closed Complete".

 

Decision Script:

(function executeRule(current, previous /*null when async*/) {
var task = new GlideRecord('sc_task');
task.addQuery('request_item', current.sys_id);
task.addQuery('state', '!=', '3'); // 3 is the value for Closed Complete
task.query();
return !task.next(); // returns true if no records found
})(current, previous);

Please mark it Correct and Hit Like if you find this helpful!

View solution in original post

4 REPLIES 4

Karthiga S
Kilo Sage

Hi @AugustoObramax 

 

1. Navigate to Flow Designer in ServiceNow.

2. Click on "New" to create a new flow.

3. Set the trigger for the flow as "When record is updated" and select the table as "sc_task".

4. Set the condition for the trigger as "Task State changes to Closed Complete".

5. Add an action to "Look up Record" from the "Requested Item [sc_req_item]" table where "Requested Item is the parent of the Task".

6. Add a decision to check if "All child Tasks of the Requested Item are in Closed Complete state".

7. If true, add an action to "Update Record" and set the "State of the Requested Item to Closed Complete".

 

Decision Script:

(function executeRule(current, previous /*null when async*/) {
var task = new GlideRecord('sc_task');
task.addQuery('request_item', current.sys_id);
task.addQuery('state', '!=', '3'); // 3 is the value for Closed Complete
task.query();
return !task.next(); // returns true if no records found
})(current, previous);

Please mark it Correct and Hit Like if you find this helpful!

Thanks for solution Karthiga S 

 

Luxo Nadappan
Tera Guru

No action needed you on this as there is an oob business rule (task closer )which will close the ritm.

 

Regards,

Luxo

Hi @Luxo Nadappan 

 

Greetings!!

 

To do this, just check the OOTB Flow / workflow. 

 

https://INSTANCENAME.service-now.com/workflow_ide.do?sysparm_nostack=true&sysparm_use_polaris=false

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************