Cancelling a source task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2014 12:42 PM
When a request is submitted for purchase and is approved a Catalog Task is created to source this item. The task is created on the Source Request workflow but there is a wait condition on the Procurement Process workflow that does not move on until the item is sourced. If the Catalog task is cancelled on the Source Request workflow it is not recognized on the Procurement workflow so this workflow will not move beyond the wait condition and close the request.
I need to possibly add an 'IF' statement in the Source Request Workflow to recognize if the state changes to cancelled on the source Catalog task, the requested item associated with this task on the Procurement Process workflow is updated with a state of cancelled as well. Doe anyone know what would be the best method to accomplish this. I may have several other RITM associated with the REQ so I would only want to cancel the RITM associated with the item to be sourced.
Source Request Workflow
Procurement Process Workflow
I added an 'IF' statement in the Source Request workflow with the following code but it is not accomplishing what I need.
function ifScript() {
if (current.state == 'Cancelled') {
var isSCTask = checkSCTask();
var isItem = checkItem();
if (current.state.changes() && current.state=='cancelled') {
var event = "approval.cancelled";
if (isSCTask)
event = "sc_task.approval.cancelled";
else if (isItem)
event = "item.approval.cancelled";
gs.eventQueue(event, current, gs.getUserID(), gs.getUserName());
}
}
return 'yes';
}
return 'no';
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2015 02:04 PM
That source request workflow runs at the request level, so if it is cancelled, it makes sense that it would affect all of the RITMs. However, out of box, nothing except the sourcing task relies on this workflow. So if it is cancelled, it isn't going to prevent anything else from doing it's job.
I have a workflow that runs on sc_request_item, and I do make that workflow wait until the item is sourced.
There isn't a built in mechanism that I'm aware of to watch for the cancelled state of the sourcing task. If you want your RITM to behave differently, depending on the cancel, you'll need to run a script in the source request workflow. Something like:
var workflow = new Workflow();
var grRitm = new GlideRecord('sc_req_item');
grRitm.addQuery("request",current.sys_id);
grRitm.addQuery(sourced,false);
grRitm.addQuery(sourceable,true);
grRitm.query();
while (grRitm.next()){
//cancel all the workflows, where current is a task record with a workflow context
workflow.cancel(grRitm);
}
}
I'm making the assumption that you don't want to cancel any RITMs if you have already sourced them, and don't want to cancel any RITMs for non-sourceable items.