Cancel button returning to current form

  • 7 November 2017
  • 1 reply
  • 78 views

Badge +4

What would be the best ways to return to current form when you press Cancel button? I was looking for the confirmation message on cancel button as well. After struggling to get perfect solution on this forum, I managed to find workaround below on this issue.

 

1. Disable existing/default Cancel button by adding below rule on the button.

210431_pastedImage_2.png

2. Create a JavaScript button called "Cancel" and add JavaScript function name, "DoRedirect()" under Advanced -> Client click field 

 

 210418_pastedImage_1.png

 

2. Place your new JavaScript button on existing Cancel button. 

210432_pastedImage_3.png

3. Select Form Settings -> Custom JavaScript -> add below code

 

function  DoRedirect()
{
    if (confirm("Are you sure you want to cancel? if you cancel now, you will lose any data entered! Press OK to continue, or Cancel to stay on the current page.") == true) {
         window.top.location.href= "http://<YourSiteURL>/Lists/<ListName>" ;
return true;
    } else {
       
return false; 
    }
}

210434_pastedImage_5.png

 

 

4. Save your changes and publish it. Have fun!!

 

 

Reference:- Redirect URL when user clicks Cancel Button 


1 reply

Badge +3

Hi Swap,

if you only need to return to the same form when you click Cancel button, so you dont need any JS.

you can simply go to the button's Advanced settings ,  in the Redirect URL field, past the "New Item" URL

 

Reply