How to make a UI Action cancel a request?

LMR
Mega Expert

I have a UI Action on the Catalog Task [sc_task] table that is supposed to...

On the Catalog task: Sets the State to Closed Cancelled, sets the Active field to false, populates Work Notes with Additional Comments to "Request Cancelled", kills the Active workflow and its contexts, does the previously listed things for all successor Catalog Tasks.

On the RITM: Sets the State to Closed Cancelled, sets the Stage to Request Cancelled, sets the Active field to false, populates Work Notes with Additional Comments to "Request Cancelled", kills the Active workflow and its contexts

What I Observe:

Nothing happens on the RITM level.

Everything on the Catalog Task works except the workflow isn't cancelled and the successor tasks are generating.

find_real_file.png

UI Action Form:

find_real_file.png

UI Action Script:

find_real_file.png

find_real_file.png

9 REPLIES 9

gauravchoudhury
Tera Guru

Hi Lea,



In case, you haven't read or referred to this thread. Also, try this link for further reference if it helps you.


I have not read these yet but I will immediately. Thank you!


samiul1
Tera Expert

I have tried the below script in my instance and worked as per the requirement:




function cancelTask(){


if(confirm('Are you sure you want to cancel your Request?')) {


//Call the UI Action and skip the 'onclick' function


gsftSubmit(null, g_form.getFormElement(), 'cancel_sc_task');


}


return false;


}




//Code that runs without 'onclick'


//Ensure call to server-side function with no browser errors


if (typeof window == 'undefined')


updateTaskAndRITM();




function updateTaskAndRITM(){


current.state = -6; //value for Cancelled


current.work_notes = 'Request Cancelled';


current.comments = 'Request Cancelled';


current.update();



var reqItem = new GlideRecord('sc_req_item');


reqItem.get(current.request_item);


reqItem.comments = 'Request Cancelled';


reqItem.work_notes = 'Request Cancelled';


reqItem.state = -6; //value for Cancelled


reqItem.update();



new UIActionUtils().approvalsNoLongerRequired(current.sys_id);


}


Hello Samiul,


Once my instance wakes up I will try this code. Thank you so much.