Cancel confirm window after clicking cancel button

jesusemelendezm
Mega Guru

Hi SN folks,

 

What can I use to configure a confirm pop up - when clicking cancel button on the change form. If user press cancel - It will ask confirmation, if press OK - cancel change- if cancel It must return to change form without cancelling the record.

 

Thanks for your help.

1 ACCEPTED SOLUTION

attachment seems not be working for me ....



this is the code ...


Note : check the 'client' checkbox and in 'onlick' field , paste this cancelTicket();



function cancelTicket(){


      var answer=confirm("Are you sure you want to cancel this record?");


      if (answer==true)


              {


              gsftSubmit(null, g_form.getFormElement(), 'cancel_change'); //MUST call the 'Action name' set in this UI Action


      }


      else


              {


              return false;


      }


}



if(typeof window == 'undefined')


      {


      current.state = 8;


      current.update();


      action.setRedirectURL(current);


      gs.addInfoMessage('The current change request has been cancelled.');


}


View solution in original post

32 REPLIES 32

Kalaiarasan Pus
Giga Sage

this should help



                        var answer=confirm("some message");


                      if (answer== true)


                            {


                            //your script to ok should come here


                      }


                      else


                            {


                            return false; //stops the submission of form


                      }



mark the question as answered if it helps


Capture.JPG


Hi Jesus,



confirm box can be used only in client side scripting. To use Kalaiasaran's code, you need to check the client checkbox on your UI Action.



Go through this Guru post that explains how to use client side and server side code in an UI Action.


http://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/



Hope that helps.


Mandar


Mandar, Thanks a lot. It works now. However when the condition is true. It is not cancelling the change. It is popping up the confirmation though.



function runClientCode(){


var answer=confirm("Are you sure you want to cancel this record?");


  if (answer==true)


  {


  current.state = 8;


current.update();


action.setRedirectURL(current);


gs.addInfoMessage('The current change request has been cancelled.');


  }


  else


  {


  return false;


  }


}