Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

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.

this BR is on catalog task table right?

Yes its on catalog task table - "sc_task"

on line 18- cannot we write gr.addQuery('request_item',ritmId)?