UI Action for requested item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 11:15 PM
I have created a UI Action with button "Cancel Request" in the Requested Item.
Currently I have 2 issues as per below.
Issue 1
How to automatically insert the "Close Notes" with the Statement "Cancel Request by Requester" when Agent click on the "Cancel Request" button in Requested Item form?
Issue 2
How to automatically changes the Approval table (sysapproval_approver) in the Requested Item form from "Requested" to "No Longer Required" when Agent click on the "Cancel Request" button in Requested Item form?
The configuration as per below.
Table
Requested Item (sc_req_item)
Condition
current.approval == 'requested' && (gs.hasRole("bbraun_catalog_fulfillment_email") || gs.getUserID() == current.opened_by || current.u_requested_for == gs.getUserID())
Scripts
function reject() {
g_form.setMandatory('close_notes', 'true');
var answer = confirm("Are you sure you want to Cancel Request?");
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'cancel_request'); //MUST call the 'Action name' set in this UI Action
} else {
return false;
}
}
if (typeof window == 'undefined') {
current.state = '4';
current.approval = 'Cancelled';
//sysapproval_approver.state = 'not_required';
current.setWorkflow(false);
current.update();
}
Thank you in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 12:00 AM
HI @TMKAM ,
1)add current.close_notes = "Cancel Request by Requester"
2)Cancel the workflow this would cancell all the approvals attached to the RITM , add this line
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 12:16 AM
Thank you for the solution but I'm not expert in these scripts and how do I put the solution into the current scripts i posted above?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2023 09:34 AM
Hi @TMKAM ,
did my reply answered your question , if so
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 01:18 AM
Hi @TMKAM
I have added those lines your code, try this
function reject() {
g_form.setMandatory('close_notes', 'true');
var answer = confirm("Are you sure you want to Cancel Request?");
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'cancel_request'); //MUST call the 'Action name' set in this UI Action
} else {
return false;
}
}
if (typeof window == 'undefined') {
current.state = '4';
new Workflow().cancel(current); //cancel the workflow
current.close_notes = "Cancel Request by Requester"; //update close notes
current.setWorkflow(false);
current.update();
}
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025