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
check this link
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- 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.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- 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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- 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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader