Pop up to confirm cancellation

shristy2
Giga Expert

Hi All,

I have the requirement that : On the incident form their is incident status code as cancelled.

find_real_file.png

When the user clicks on that i want a pop up saying : " Do you want to cancel this incident " and two buttons should be their i.e., Yes or no.

If user clicks yes the ticket should get cancelled and if he clicks no then it should remain in the same page.

Kindly provide your input.

Regards,

Shristy

1 ACCEPTED SOLUTION

raveena2
Kilo Expert

Hi shrishty,


Try this code


function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}




var value = g_form.getValue('incident_state');// field name
if(value==12) // field value
  {
  if(confirm("Do you want to cancel"))
{
g_form.save();
}
    else
    {
    g_form.setValue('incident_state',oldValue);
    }


  }
}



Regards,


Raveena Bhatia



PS:Mark this answer as correct or useful or hit like


View solution in original post

14 REPLIES 14

Gurpreet07
Mega Sage

Hi Shristy,



This could be done in following steps.


1. Create an onChange Script for 'Incident Status Code' field


2. Display a new GlideDialog window using script .


3. The Dialog window should point to a UI Page having these two buttons.


4.   Return false if user select 'No' else return true.


Gurpreet07
Mega Sage

Here find more about GlideDialog Window


GlideDialogWindow API Reference - ServiceNow Wiki


raveena2
Kilo Expert

Hi Shristy,



You can write a onChange() client script for that field you should check the value of list is cancelled or not.


You can add the confirm('message to be displayed ') for the popup



Regards,


Raveena Bhatia


srinivasthelu
Tera Guru

Hi Shirsty,



You need to write a onchange client script on the incident status field with confirm box. With something like below



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }




  if(g_form.getValue('u_incident_status_code')=='what ever the status code value for cancel replace it')


  {


  if(!confirm("Do you want to cancel the ticket"))



  g_form.setValue(oldValue);


  }


    //Type appropriate comment here, and begin script below


 


}



Thanks


Srinivas