Cancel UI action on Catalog task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 05:20 AM
I need a cancel button on catalog task form. When Cancel UI action is clicked, the sc_task state should be changes to 'Close cancelled' and all its approval along with SLA's should also be cancelled and made inactive.
Please suggest an possible way to achieve this requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2024 05:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2024 02:49 AM
Why do you need to cancel? You can use the closed skip if required which is OOTB and you can define SLA etc on the same. A new UI Action will increase technical debt and overhead in future releases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2024 03:50 AM
are you having approvals on catalog task or RITM?
try this in the UI action for approval on both levels
The UI action should be server side
cancelTask();
function cancelTask() {
// Set the state to 'Close cancelled'
current.state = '4';
current.update();
// Cancel all approvals
var approvalRecord = new GlideRecord('sysapproval_approver');
approvalRecord.addQuery('document_id', current.sys_id).addOrCondition('document_id', current.request_item);
approvalRecord.addEncodedQuery('stateINrequested');
approvalRecord.query();
while (approvalRecord.next()) {
approvalRecord.state = 'cancelled';
approvalRecord.update();
}
var slaRec = new GlideRecord('task_sla');
slaRec.addQuery('task', current.sys_id);
slaRec.query();
while (slaRec.next()) {
slaRec.state = 'cancelled';
slaRec.active = false;
slaRec.update();
}
// Redirect to the task list
action.setRedirectURL(current);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2024 08:37 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.