Can you redirect to the previous page after a save or cancel?

  • 1
  • Question
  • Updated 5 years ago
  • Answered
I am wondering if the page you redirect to after a save or cancel can be set to "whatever page was before this one". 

Use case -- 

My users often use their task list (a modified version of the home page) to work through their tasks. E.g, 
  • Start at task list on hompepage
  • Click on task name to navigate to task detail page
  • Edit, complete, save task
  • Go back to task list on homepage
  • Begin again
However sometimes they may be working on a specific contact with multiple operations: 
  • Start on contact detail page
  • create new follow up task
  • Go back to contact detail page to do something else
In both cases the user wants to go back to the page they were before the task page to continue doing something. But the page title component only lets me put a single URL, albeit one with dynamic tokens. 

Is there a token for "page that was before this one"? 

Thanks! 
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb

Posted 5 years ago

  • 1
Photo of Pat Vachon

Pat Vachon, Champion

  • 44,396 Points 20k badge 2x thumb
How is the page you're redirecting from being navigated? Can you pass a URL parameter into the page to use as your redirect ID?

"/{{$Param.redirId}}"
(Edited)
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Great idea...not sure whether I can control the URL though. 

The tasks are most often being navigated to from a table of tasks. Either a table on the homepage (global task list) or an "open tasks" table on the contact detail. 

Not sure if there is a way to insert this parameter into the task name URL that's generated within the table? 
Photo of Pat Vachon

Pat Vachon, Champion

  • 44,396 Points 20k badge 2x thumb
Well. Hmmmm ... you can control it sometimes. You are creating new tasks and then wanting to come back to the original record that the user clicked from to create the task. What are you using to get to the "NewTask" page? Row Action, Button, javascript?
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Pat, you're right. I realized I misstated the second scenario in my original post. The workflow would be more like, 
  • Start on contact detail page
  • navigate to existing task from the open tasks list
  • Edit, close, save task
  • Go back to contact detail page to do something else
So when creating new tasks I have control but the challenge seems to be when accessing existing tasks from the activity list that is either global or specific to a contact and wanting to go back to the original page. 
Photo of Pat Vachon

Pat Vachon, Champion

  • 44,396 Points 20k badge 2x thumb
Wait, I'm missing the obvious.
Photo of Pat Vachon

Pat Vachon, Champion

  • 44,396 Points 20k badge 2x thumb
The Task is related to the record you'd like to navigate back to.

"/{{What}}" or "/{{Who}}"

Using mustache you can insert the correct one in the redirect.
{{#What}}/{{What}}{{/What}}
{{#Who}}/{{Who}}{{/Who}}
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
So unfortunately the two pages I want to redirect to would be either 

/{{who}} OR /home.jsp

But would want it to be smart enough to know which one was the referring page and go back there. That's why I wondered if there was a token for "last page before this one or something similar"
Photo of Pat Vachon

Pat Vachon, Champion

  • 44,396 Points 20k badge 2x thumb
Oh. sometimes from the home page. I see. hmmmm .... I'm sure you can get the browser history, but I'm not sure to do that myself.
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,686 Points 5k badge 2x thumb
Use a javascript snippet with the following content:

window.history.back();
Photo of Pat Vachon

Pat Vachon, Champion

  • 44,396 Points 20k badge 2x thumb
See.... javascript. Can't wait til it comes to me that easily. A one liner snippet!

I sometimes feel as though I'm playing t-ball and wildly swinging the bat way too high over and over .....  :( It's really hard to miss in t-ball for anyone with arms.

I'm still typing with my nose. :P
(Edited)
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
@Moshe, that is awesome -- thanks!

Just to clarify, would I leave the "redirect after save" field in the page title blank, and then for the save button, run multiple actions that would first save the model, then call the javascript snippet? 

Thanks again. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,828 Points 20k badge 2x thumb
Your clarification is correct.  Use a multiple actions sequence for the button...