- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2020 01:52 PM
I have a workflow that is generating multiple RITMS and SC_tasks from a list collector.
Many thanks to
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
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Service Portal
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2020 05:14 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2020 05:14 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2020 08:10 AM
Thansk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2020 10:35 AM
You are welcome!