The CreatorCon Call for Content is officially open! Get started here.

close the catalog item when all the tasks are closed complete

saini
Tera Expert

i need to write a business rule where, when all the catalog tasks of the catalog item are closed complete then the catalog request item is also closed? Thanks

1 ACCEPTED SOLUTION

Sukhbir Singh2
Giga Guru

If you are opening all the tasks from workflow, then insert a join activity in front of all catalog task activities. The join activity will wait for all the tasks to be closed. Then insert a set activity to set the state of RITM to closed complete. This should be the preferred approach.

 

find_real_file.png

 

If for some reason you need a BR to close the RITM, use the following code in your after BR

 

find_real_file.png

find_real_file.png

In the condition field of the BR, use 

''+current.request_item.cat_item == "060f3afa3731300054b6a3549dbe5d3e" // sys_id of the catalog item so that it only triggers on for a specific catalog item

 

 

Please mark my answer as correct/helpful, if it helps.

View solution in original post

16 REPLIES 16

Hi Sukhbir,

I've got a similar request request/issue from a customer. They are creating manual tasks and when one gets closed, the RITM closed too even if there are other active tasks when it should only close when all tasks are completed. Would this work in my case too? They also want to be able to close a RITM when it has active tasks - not best practice perhaps but this is their requirement.

Thank you!

Hi Amelie

I can see flaw in their process. The RITM should not close until all tasks are closed. Tasks are opened under the umbrella of RITM. You can suggest them to correct it.

This code may not work exactly because there is a parallel piece of code/workflow which is allowing the RITM closure when a task is closed. You need to block that and this code may start working.

Can you share more details about the workflow and requirements? 

Thanks

Hi Sukhbir,

This is my recent post

https://community.servicenow.com/community?id=community_question&sys_id=fdd397cbdb928910bb4a474d1396198d

The customer is using the Item Designer Fullfilment workflow and the functionality is per OOTB. I'm not sure why RITM is getting closed when manual tasks are closed, as this used to work fine before when the only tasks of a RITM were the ones created in the workflow. I thought the workflow doesn't pick up the manual tasks but somehow it does and doesn't check if there are other active tasks.

This customer in particular is quite difficult, I've offered a simple solution to check for active tasks when the state of a RITM changes and abort the action if there are, but they said they still want to be able to close a RITM even if it has open tasks even if it's not best practice.

Shakeel Shaik
Giga Sage
Giga Sage

Hi saini,

 

If you want to write Business Rule to achieve this requirement,

Then you need to Create After Business Rule on Catalog Task.

 

 

Please Check and Let us know

Thanks 🙂

Thanks,
Shakeel Shaik 🙂

 

Here is the script for 

Create After Business Rule on Catalog Task.

 find_real_file.png

(function executeRule(current, previous) 
{

	

var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', current.request_item);
gr.query();
if (gr.next()) 
{

gr.state=3; //3 is my Closed COmplete valu, add yours
gr.update();

}
})(current, previous);

 

 

If my answers is Helpful to you, Please mark as Correct Answer/Helpful

Please check and Let us know.

Thanks 🙂

 

Thanks,
Shakeel Shaik 🙂