How to make a UI Action cancel a request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 02:35 PM
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.
UI Action Form:
UI Action Script:
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 10:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 07:55 AM
I have not read these yet but I will immediately. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 11:47 PM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 07:56 AM
Hello Samiul,
Once my instance wakes up I will try this code. Thank you so much.