+ Start a Discussion

How to get the Return URL???

Hi there,


I have a custom object called Job and I created a custom view in visualforce for that object and that is the view that I am using when I go to view a job record.  Now I have another visualforce page where I am listing all the Jobs. When the user clicks a job on that list I am also taking them to the same visualforce page that I created above for the job. I have a back button on the visualforce page. What I want to do is when I click the back button I want to go back to the return URL where it came from. So if I go to the job visual force page from the visualforce page that I created to list all jobs then I should go there. If I go to the job record through a contact(contact is related to job), then I want to go to the contact page or what ever page that I came from. Is there a way to get the return URL in salesforce? How would you approach this? Thanks.




I think there's PageReference method that should be able to bring you back to the previous url.. but perhaps wishful thinking.  See "PageReference" in the VF Dev docs:



At the very least you could hard code your Job Detail VF page to go back to the Jobs List page via PageReference.