swap

Cancel button returning to current form

Blog Post created by swap on Nov 7, 2017

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.

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

 

 

 

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

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; 
    }
}

 

 

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

 

 

Reference:- Redirect URL when user clicks Cancel Button 

Outcomes