Create 'Cancel' Button to Cancel Request for Change Request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2025 08:37 AM
Hi all ,
I would like to add a 'Cancel' button to the Change Request (change_request) form.
📌 Requirement:
At the top-right corner, there should be an option to press 'Cancel', which should:
Cancel the current change request (e.g., set the state to Canceled)
Exit the form
Undo the attempt to submit the request
As shown in the attached screenshot, I’d like this button to behave similarly to the 'Delete' or 'Update' buttons, but specifically to cancel the request gracefully.
Can anyone suggest the best way to implement this — using a UI Action or another approach?
If using a UI Action, please provide the correct steps to create it, the script code, and the UI Action order (as the order affects whether the button is displayed properly).
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2025 09:01 AM
This appears rather straightforward and similar to the UI Action on the Request table.
Create a UI action
Select Show Insert and Show Update
In the Script field use this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 02:42 AM
var changeConfirmCancelDialog;
function cancelChangeRequest() {
g_form.setValue("state", "4");
}
if (typeof window == 'undefined') {
runCancel();
}
function runCancel() {
current.update();
action.setRedirectURL(current.getTableName() + '_list.do');
}
I have no idea about this line: var changeConfirmCancelDialog;. I know this is for the Change confirmation popup, but I don’t know exactly how it works. Please explain.
Also, how does this condition work: new ChangeFormUI(current).isCancelAvailable()? Please explain how this condition works.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 02:58 AM
ChangeFormUI script include extends ChangeFormUISNC script include.
It has isCancelAvailable() function which returns true/false based on some check
Since you are using Change State Model transition, it will check if it's allowed to move to Cancel state based on current state.
it calls another script include "ChangeRequest"
I hope this much details should be sufficient for you to debug and understand further
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
06-30-2025 02:40 PM
Hi @UdhayakumarS559 ,
There is only one straight forward method - create a UI action as you have already stated.
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/