Reload form if the user clicks on Cancel button on the confirmation box

shravan3
Kilo Expert

Hi,

Please let me know how can reload the form if the user clicks on the cancel button on the confirmation box ?

I have written below code but it is not working as expected. Below code is reloading the form but it is saving the changes which was entered .

function onSubmit() {

if ((g_form.getValue('state') == 17) )){

var answer = confirm('Do you want to really Reject & Close the change?');

if(answer == false){

location.reload(true);

}

}

}

Thanks & Regards,,

Shravan Kumar

1 ACCEPTED SOLUTION

HI shravan,



Plesae do following changes in the code


function onSubmit() {



if ((g_form.getValue('state') == 17) ))


{


var answer = confirm('Do you want to really Reject & Close the change?');


if(answer == false)


{


window.top.location.reload(true);


return false;


}


}


}


View solution in original post

9 REPLIES 9

Shishir Srivast
Mega Sage

Hi Shishir Srivastava<https://community.servicenow.com/people/explorenow?et=watches.email.thread>,



Thanks .



It is not working for me.





How to reload the form if the user clicks on the cancel button on the confirmation window?



Thanks & Regards,


Shravan Kumar


You could try to execute with: window.location.reload();


shubh1992
Tera Guru

Hi Shravan,



PLZ find the code below it will work for u:-


function onSubmit() {



if ((g_form.getValue('state') == 17) ))


{


var answer = confirm('Do you want to really Reject & Close the change?');


if(answer == false)


{


window.top.location.reload(true);


}


}


}



PLZ mark this correct if it resolved your issue or feel free to ask if u still have any queries.


Regards,


Shubh