How to set up a pop up window using Onchange clinet script???

naveenmyana
Giga Expert

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.

Capture.PNG

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..

9 REPLIES 9

antin_s
ServiceNow Employee
ServiceNow Employee

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


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...chage.PNG



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();



}


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();



}



});




}


antin_s
ServiceNow Employee
ServiceNow Employee

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


lakshminarayan4
ServiceNow Employee
ServiceNow Employee

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