
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2017 01:55 PM
I have a UI action that is a Client side and Server Side. I already have an onClick defined for the UI action. However, my user's want a confirmation box to popup asking if they are sure they want to complete the action.
Does anyone know how I can do this?
Thanks,
Stacy
Solved! Go to Solution.
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2017 02:01 PM
Within your on-click script add something like the following:
var usrResponse = confirm('Are you sure you want to do Something?');
if (usrResponse == true) {
DO THE REMAINDER OF YOUR SCRIPT HERE
} else {
return false
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2017 01:58 PM
Hi Stacy,
You can have something like below in your onClick on client side to get confirmation from user to proceed further.
var answer=confirm("Are you sure you want to complete the action?");
if (answer==true)
{
gsftSubmit(null, g_form.getFormElement(), 'cancel_change'); //MUST call the 'Action name' set in this UI Action
}
else
{
return false;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2017 02:01 PM
Within your on-click script add something like the following:
var usrResponse = confirm('Are you sure you want to do Something?');
if (usrResponse == true) {
DO THE REMAINDER OF YOUR SCRIPT HERE
} else {
return false
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2017 10:04 PM
Hello stacy,
you can write something like
on UI action ::onclick : myClientSideFunction()
script::
function myClientSideFunction(){
if(confirm("Are you sure you want to perform this action?")){
gsftSubmit(null,g_form.getFormElement(),'actionnamevalue');
}else{
return false;
}
}
if(typeof window == 'undefined'){
myServerSideFunction();
}
function myServerSideFunction(){
your server side logic what ever you wanna write;
}
Please mark it helpful or correct if it fulfills the request.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2017 10:29 PM
You can go through the wiki article- Scripting Alert, Info, and Error Messages - ServiceNow Wiki
You can write an onsubmit client script-
Script code:-
function onSubmit() {
var ConfirmOrNot=confirm("Do you want to submit?");
if (ConfirmOrNot==true)
{
return true;
}
else
{
return false;
}
}