UI action : Add Confirm Window on the click of cancel button
Import
·
Feb 10, 2023
·
article
Hi All,
Hope you are doing great.
In this article we will try to get the solution on below use case
Use case :
Can I use to configure confirmation popup - when i click cancel button in change form. If the user presses cancel, he will be asked for confirmation, and if he presses ok, the changes will be canceled. If he cancels, he has to go back to the change table without canceling the record.
Solution :
- Check the 'client' checkbox and in 'onlick' field , paste this cancelRecord();
function cancelRecord(){
var answer=confirm("Are you sure you want to cancel this record?");
if (answer==true)
{
gsftSubmit(null, g_form.getFormElement(), 'cancel_change'); //MUST call the 'Action name' set in this UI Action
}
else
{
return false;
}
}
if(typeof window == 'undefined')
{
current.state = 8; /// CAncel the record
current.update();
action.setRedirectURL(current);
gs.addInfoMessage('The current change request has been cancelled.');
}
Please be sure to bookmark this article as well as mark it as Helpful if you thought it was helpful.
Regards,
Amit Gujarathi
View original source
https://www.servicenow.com/community/developer-articles/ui-action-add-confirm-window-on-the-click-of-cancel-button/ta-p/2406091