- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2017 08:15 AM
SN Team,
In the process of modifying an existing Cancel Change UI Action. The goal is for the new UI Action to provide an confirmation window before proceeding with the Cancel Change request.
I have reviewed the following articles and here is what I came up.
Reference 1:
https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
Reference 2: Re: Cancel confirm window after clicking cancel button
Main issue: Confirmation window opens fine and allows user to Cancel. Having trouble getting the Cancel Change request to execute when OK is selected.
Looking for some help figuring out how to get the moveToCancel(); function to execute.
//moveToCancel();
//confirmCancel();
function confirmCancel(){
var answer=confirm("Are you sure you want to cancel this record?");
if (answer==false)
{
// gsftSubmit(null, g_form.getFormElement(), 'cancel_change'); //MUST call the 'Action name' set in this UI Action
alert('This change was not cancelled');
return false;
}
else
{
moveToCancel();
return true;
}
}
function moveToCancel(){
action.setRedirectURL(current);
if (new ChangeRequestStateHandler(current).moveTo("canceled"))
current.update();
}
}
Thanks,
Jahanzeb
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2017 10:11 AM
- function confirmCancel(){
- var answer=confirm("Are you sure you want to cancel this record?");
- if (!answer)
- {
- alert('This change was not cancelled');
- return false;
- }
- else
- {
- gsftSubmit(null, g_form.getFormElement(), 'cancel_change'); //MUST call the 'Action name' set in this UI Action
- }
- }
- function moveToCancel(){
- action.setRedirectURL(current);
- if (new ChangeRequestStateHandler(current).moveTo("canceled"))
- current.update();
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2020 10:55 PM
Hi,
issue with syntax and script
function Cancelconfirm(){
var answer = confirm('are you sure you want to cancel?');
if(answer == true){
gsftSubmit(null,g_form.getFormElement(),'cancel');
}
else{
return false;
}
}
if(typeof window == 'undefined')
cyclemove();
function cyclemove(){
current.phase='cancelled';
current.active=false;
current.update();
action.SetRedirectURL(current);
}
Regards
Ankur
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-09-2020 11:10 PM
Hi Ankur,
thanks for reply i tried same but when i select ok from confirmation box it won't cancel the request it just redirect to previous page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2020 11:42 PM
Hi,
please check the field name phase is proper and the value as well
Also update as this
action.setRedirectURL(current);
Regards
Ankur
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-09-2020 11:53 PM
one question.. onclick is cancelconfirm and client checkbox is true.
is this correct??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2020 11:56 PM
also i tried with this above changes.. but request won't get cancelled.