RITM not closing when SC_task is closed

Leslie Hornyak
Tera Contributor

I have a workflow that is generating multiple RITMS and SC_tasks from a list collector.

Many thanks to @Brad Bowman  for helping me get this completed using a workflow script.  A RITM is created with the master collection of apps requested and a separate RITM for each individual APP along with a corresponding SC_Task for that APP assignment group.

 

The issue now is that when i close any of the individual SC_Tasks, the associated RITM is not getting updated to a closed complete State.

 

Ive tried to add a BR where it checks the status of the SCTask record for closed complete , incomplete or skipped and then force the workflow .... 

 

var ritmRec = new GlideRecord('sc_req_item');

if(ritmRec.get(current.request_item)) {

new Workflow().broadcastEventToCurrentsContexts(ritmRec, 'update', null);

}

})(current, previous);

 

Ive also tried to set a wait for condition in the workflow but neither seem to be working correctly.

TIA

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

You probably only have one workflow running - on the original RITM, not on each one created by the script - which sounds like it's probably OK in this simple case, but since the tasks are created by script, even if there were a workflow running on each RITM, it still wouldn't catch a task closing. 

You'll want your after Update Business Rule on sc_task to have Filter Conditions for the State changing to one of the closed ones (or you can use Active changes to false) and when Request Item -> Item (show related fields) is this Catalog Item, so that it doesn't run on every task closure.  Your script would look like this to set the State of the RITM

var ritmRec = new GlideRecord('sc_req_item');
if(ritmRec.get(current.request_item)) {
//if you want the RITM to be Closed Incomplete when the Task is Closed Incomplete, etc
ritmRec.state = current.state;
//or if you want the RITM to always be Closed Complete, use the next line instead
//ritmRec.state = 3;
ritmRec.update();  

If this gets more complex you could add variable population and workflow starting to your original script and remove the task creation.  Then make sure the same script accounts for it running against the original RITM, and for each created one, so that it doesn't create RITMs again every time it runs.  Doing this would allow you to add catalog task(s), and whatever else you need to do before each workflow and RITM is closed, and you wouldn't need business rules to intervene.  I have a couple of catalog items running like this if you need an example.

View solution in original post

7 REPLIES 7

Allen Andreas
Administrator
Administrator

Hi,

Sorry, not fully sure what all you have going on here, but if you're making RITMs through script as well as catalog tasks and they aren't part of a workflow, but instead manual, then the catalog tasks being closed will not roll-up to the RITM to also close that.

You'd want to make a business rule on the sc_task table that upon update to one of those states as well as possibly setting up some dot-walk to the associated RITM catalog item (so that this BR isn't always running on other non-related sc_tasks) that the request item is then Closed (which will then review if the parent Request also needs to close or not).

Again, sorry, but not sure how a workflow is associated here if these are spawning from script in another RITM workflow as you can use the cartAPI or you can just initialize and make these records (at which point a workflow is not associated).

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

I have an order guide that is being completed by new hire manager for provisioning. Each item was getting a workflow assigned depending on the group responsible.

For this particular workflow we created the script to divide each application request to a separate RITM and SCTask but it was done in the Workflow.This worked great except that it stops the workflow process. Can i create a wait for condition in the workflow to fix this or it will have to be done with a BR?

I tried using a BR to fix it already but i may not be correctly setting up the rule.

In the BR i set it on the SCTask table as an after rule and the conditions were if the SCTASK was to check whether it was  closed complete, incomplete to update the workflow. 

Not sure of how i would do this otherwise as i found this the best way to work the tickets. ( I am fairly new to SN) 

 

 

Hi,

Perhaps you can link to your thread where someone else assisted you so we know what all you're talking about?


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Yes, thank you..

 

 

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

 

 

This was the original thread and the assistance i received.