Redirect to another page when 'cancel' button is clicked

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
I have a link on a main dashboard page, which when clicked redirects to an edit record page with the main dashboard page as the nexturl(). When I click on save button, it works as it should and redirects the page to main dashboard. However, when I click on the cancel button, it stays on the same record but in view mode. Is there a way for the nexturl to work with cancel button as well?

Thanks.
Photo of Rizu

Rizu

  • 210 Points 100 badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
Natively the cancel button just amends an href='#' to the call. So you would need to make a custom cancel button if you wanted to control the redirect.

This is straight from the "Magic Button" app, 

"<a class='Vibrant Success' onclick='DoSaveCancel()' href='#'>Cancel</a>"

So you would need to add your end URL to the href.

Another option is to pass the "Cancel" URL via the original button push.
Basically it would write to a URL field, then your cancel button would use that URL in the cancel href.

Say my [Cancel URL] is field 20, you can add

&_fid_20="&URLEncode(www.google.com)&"

Then your Cancel button would look like:

"<a class='Vibrant Success' onclick='DoSaveCancel()' href='&[Cancel URL]&'>Cancel</a>"
Photo of Rizu

Rizu

  • 210 Points 100 badge 2x thumb
I understand. Thank you!