I'm trying to integrate a Custom VisualForce Page in Lightning experience and I'm facing some issues with navigation. My question is how can I detect where the user accesses my custom page from? For example:

I'm overriding the Account's Edit button so when I want to edit an Account I use my custom VF page for that. But I can access the edit page from the Account's listing page and from the record's detail page. Please see the screen shot below:

  1. Edit from Account's listing page:

enter image description here

  1. Edit from the record's details page:

enter image description here

Does anyone knows a way I can 'tell' my controller that the user is coming from the detail page or from the object's listing page so I can use this to redirect back to the relevant page? I would appreciate any help! Thanks!

1 Answer 1


If all you want to do is go back to the previous page, I believe you can use Salesforce one's built in navigation.(Which if I'm not mistaken, work in Lightning experience as well)


sforce.one.back(true); // I should note this is a Javascript function, not Apex

As noted in the documentation here, it is equivalent to hitting the browser's back button. And the parameter true in my example is optional and indicates whether you'd like the page to refresh.

Hope this helps!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .