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

TJW2
Mega Guru

You have 2 posts for this question, please remove one of them.

On your workflow, add condition on your 'Catalog Task Activity' (activity.result==10). Create another workflow line to: Set stage 'Request Cancelled' and END

Let the OOB BRs run on RITM and REQ to close as required.


For clarity are you saying to set the condition to the activity (sc.task?). Also on the additional workflow line would i set the Stage or State? The state is what is located on the Catalog Task.


TJW2
Mega Guru

1. Right click on 'Catalog Task Activity' and select 'Add Condition.
2. Add the Condition as in the attached pic
3. Double click on 'Always' condition and modify as shown, Make sure to remove condition (true)
4. You now have 2 Conditions for when this task completes
5. Draw the line from 'Cancel' to a Workflow Activity Set Value where you indicate the Stage as Request Cancelled

When the sc_task is closed as cancelled (state = 10, activity.result = 10), it will take the line desired in your workflow to 'Cancel' the RITM, then the REQ if only one RITM.


amatthews
Kilo Explorer

Thank you for such detailed instructions. I have created the additional condition and also updated the always condition per your instructions but cancelling the task does not update the RITM or the REQ. See attached screenshots. Are there any other suggestions?