How to set up a pop up window using Onchange clinet script???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2017 12:26 PM
Hi Everyone,
I need to create a pop up for change requests, When ever User wants to Cancel a change and put a messag like this:
You have just selected Cancel Change. Are you sure you want to cancel change? Yes or No.
If yes proceed with cancelling change if no do not update change to cancelled.
Hi ctomasi antin.s mikaelhaverinen have you ever come across anything like this one, Please help me out on this one as this is quite new for me..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2017 03:59 AM
Hi Naveen,
Can you try confirm() method instead of swal() and see how it works?
If the user has clicked cancel, the answer will be false and submit will be cancelled.
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2017 04:04 AM
Hi Selvaraj,
But our client wants to have this function only, As same pop up has been implemented for other modules as well... Anyway I am able to make the pop up window to stay, But when I clcik on Yes button, It's not working. Can you suggest any code changes here...
function Cancel()
{
// g_form.setValue('state', 10,'Cancelled');
// g_form.submit();
swal({
title: "Cancel Change",
text: ": You have just selected Cancel Change. Are you sure you want to cancel change? ",
confirmButtonText: "Yes",
showCancelButton: true,
closeOnConfirm: true,
html: true
});
g_form.setValue('state', 11,'Closed');
g_form.setValue('u_sub_state','Closed-Cancelled','Closed-Cancelled');
g_form.submit();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2017 05:40 AM
Hi Selvaraj,
Below is the code that is working fine for me...
function Cancel()
{
// g_form.setValue('state', 10,'Cancelled');
// g_form.submit();
swal({
title: "Cancel Change",
text: " You have just selected Cancel Change. Are you sure you want to cancel change? ",
showConfirmButton: true,
confirmButtonText: "Yes",
showCancelButton: true,
cancelButtonText: "NO",
closeOnConfirm: true,
html: true
},
function(isConfirm) {
if (isConfirm) {
g_form.setMandatory('u_reason_for_cancelling_change',true);
g_form.setValue('state', 11,'Closed');
g_form.setValue('u_sub_state','Closed-Cancelled','Closed-Cancelled');
g_form.submit();
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2017 05:08 PM
Cool. Glad it worked for you Naveen.
If you think my replies have helped or answered your question, can you please mark it as 'Correct' to help the community?
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2017 10:36 PM
hi,
There is a OOB "GlideDialogWindow" . you can open a dialog "onChange" event . Please find the doc here.
GlideDialogWindow API Reference - ServiceNow Wiki
From there onward you have to write "Client callable" script to do the rest of the functionality.
Thanks
- YLN