- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 12:09 AM
I have a button called "Cancel Request" on the top right corner of my form.
I want to create a alert/confirmation box with Yes and No button to prevent direct cancellation of the form.
I want a simple solution with a alert box only and not the UI Page solution. We already have a UI Action for this button but writing alert() or confirm() method of JavaScript is not working as that is Service side script.
Please help!
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 12:26 AM
Hello,
Yes you can do it as below:-
function cancelIncidents() {
var answer = confirm("Are you sure you want to cancel it?");
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'cancelincidents');
} else {
return false;
}
}
For more information check the below post:-
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 12:26 AM
Hello,
Yes you can do it as below:-
function cancelIncidents() {
var answer = confirm("Are you sure you want to cancel it?");
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'cancelincidents');
} else {
return false;
}
}
For more information check the below post:-
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 07:21 AM
Hi Saurav,
Your code is correct, but it works when client checkbox is checked in the form. But what if it is server side script and we don't have any onclick field to call a function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 12:00 PM
Hi Saurav,
Your solution is 50% correct.
Please see the below post from the community to get the solution.
Solved: While clicking the button a confirmation alert box... - ServiceNow Community
Thank you,
Abhishek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 01:02 AM