- 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 07:24 AM
Hi Karan,
I cannot give you the exact code but it is similar to the below post's solution by Imran Ahmad. The only difference is that I have not checked the client checkbox and therefore I don't have that Onclick field to call the function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 07:25 AM
Sorry I forgot to give you the link to the post
Solved: While clicking the button a confirmation alert box... - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2023 07:30 AM
Right, so you need to actually convert it to a client-side UI Action by checking the box, adding the function name in the Onclick field and the "gsftSubmit" will re-run the code in the UI Action, this time on the server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 07:59 PM
I have the same problem. Have you solved your problem