Confirm box (Yes/No) in a UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021 12:00 PM
Hello all,
I have created the following UI action and it works fine. Now I have a requirement to add the Confirm box (Yes/No) to that UI Action button.
createGSTicket1();
function createGSTicket1() {
current.transf_inc = 'true';
current.update();
action.setRedirectURL(current);
}
_____________________________________________________________________
Now I add the following code in and the Confirm box is not working.
createGSTicket1();
function createGSTicket1() {
var usrResponse = confirm('Are you sure you want to transfer this request to incident?');
if (usrResponse == true) {
current.transf_inc = 'true';
current.update();
action.setRedirectURL(current);
} else {
return false;
}}
I would appreciate if someone can help me on this issue.
Regards,
Hong
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2021 08:42 AM
Please update script as this and test once
function confirmAndTransferFromForm() {
var usrResponse = confirm('Are you sure you want to transfer this request to incident?');
if (usrResponse.toString() == 'false') {
return false; //Abort submission
}
else{
gsftSubmit(null, g_form.getFormElement(), 'transfer_incident'); //Call the Action name set in this UI Action
}
}
if (typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode() {
current.transf_inc = true;
current.update();
gs.addInfoMessage('You did it!');
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
01-09-2021 06:30 PM
toString() or the script which i have mentioned that will also work.
Updated script
function confirmAndTransferFromForm() {
var usrResponse = confirm("Are you sure you want to transfer this request to incident?");
if (!usrResponse) {
return false; //Abort submission
} else
gsftSubmit(null, g_form.getFormElement(), 'transfer_incident'); //Call the Action name set in this UI Action
}
if (typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode() {
current.transf_inc = true;
current.update();
gs.addInfoMessage('You did it!');
action.setRedirectURL(current);
}
If my answer helped you, kindly mark it as correct and close this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021 12:39 PM
Change createGSTicket1(); to somethinbg like:
function createGSTicket1(){
g_form.setValue("transf_inc ", "true");
//add all you fields required in similar manner as above
g_form.save();
}
This will allow you to save the values from the client side
P.S. Ahhh I see what you mean 🙂 You better use UI Page for that and call it by GlideDialog(). Then its easy. Take a look for GlideDialog examples (in UI Pages try with something like *yes or *confirm). Then you'll get it
Try this:
Cheers,
Joro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2021 11:06 AM
are you in Global scope or custom scope? The windows dialog code are different depend on the scope.