Cancelling Tasks

amatthews
Kilo Explorer

I need to be able close a TASK w/State of Cancelled and populate the Closed field with date & time. That action in turn needs to close the RITM w/Stage and State of Cancelled and populate the Closed field with date & time. Then that action needs to close the REQ w/Stage of Closed Complete, State of Cancelled and populate the Closed field with date & time. This only needs to occur if there is only one TASK and one RITM associated with the REQ. If other TASKs and RITMs are associated with this REQ we do not need to close the REQ. Currently we work at the TASK level not the RITM level.
I have noticed the 'Close Task' UI action cascades up and closes associated RITM & REQ, which is what I am attempting to do.

How do I determine which Business Rules, Clients scripts, ACLs, or UI policies are associated with the Close Task UI Action?

I have also checked out the following BR but not sure how they execute:
Close Parent if Required
Close Tasks Due to Cancellations

I created a BR with the code below that is closing the task, RITM, & REQ but it closes successfull instead of cancelling.

Condtion: current.state.changes() && (current.state ==10)

var gr = new GlideRecord('task');
gr.addQuery('active','true');
gr.addQuery('parent',current.sys_id);
gr.query();
if (gr.next()) {
current.setAbortAction(true);
}

if ((current.stage == 'Request Cancelled') && current.context && !current.context.nil()) {
var w = new Workflow();
var gr = new GlideRecord('wf_context');

if (gr.get(current.context))
w.cancelContext(gr);
}
current.active = false;
current.work_end = nowDateTime();
current.business_duration = gs.calDateDiff(current.work_start.getDisplayValue(),current.work_end.getDisplayValue(),false);

I also attempted to create a UI action to perform in the same manner as the Close Task ui but not sure if that is the route to go. Any suggestions would be appreciated.

UI Action info
Condition: current.state.changes () && (current.state ==10)

current.state = 10;
current.update();

6 REPLIES 6

After you set the stage to 'Request Cancelled', you are setting the stage to 'Complete' (in the End Activity). So the BRs run with a Stage = 'Request Cancelled', then rerun for a Stage = 'Complete'. Move the complete stage out of the End Activity.


Hi Terri,


Thanks for the instructions. Its very helpful. I've done step 1-5 and now its not closing the RITM when only one task associate with it. I'm not clear with your last reply to Artavia . my workflow as below. Please help me.



workflow Cancel task.png