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

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Naveen,



Please refer sample ex 4.5 on how to get confirmation from the user.


Client Scripts - ServiceNow Wiki



Please let us know if you have any additional questions.


Chay2
Mega Guru

Hi Naveen,



You need to create a UI page to pop up you can trigger from a onChange client script


this will help you https://www.servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/  


antin_s
ServiceNow Employee
ServiceNow Employee

Hi Naveen,



I hope you have an UI Action (button) for Cancelling the change. Please have the below script added in the top of the UI Action script.



  var answer = confirm("Are you sure to cancel the Change?");


  if (answer == true) {


    return false;


  }



Hope this helps. Mark the answer as correct/helpful based on impact.



Thanks


Antin


Hi Selvaraj,



I am able to create the popup window now when i click on cancel button in change form, But the issue is when I click on cancel button the pop up is just showing up like for a sec and is cancelling the change ticket. I need it to make it stay so the user can click on Yes or no buttons to cancel the change ticket. Can u please help me out with this code.



Here is the code I have written on Cancel button:


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? ",


//showCancelButton: true,


confirmButtonText: "Yes",


confirmButtonText: "NO",


closeOnConfirm: true,


html: true


});


g_form.setValue('state', 11,'Closed');


g_form.setValue('u_sub_state','Closed-Cancelled','Closed-Cancelled');


g_form.submit();



}