+ Start a Discussion
Ryan GreeneRyan Greene 

Return URL - Maybe I'm over thinking this

I currently have a Hyperlink from a custom object "Document" to a VF page. This hyperlink is displayed on the related list on the Lead, Opp, and some other custom objects. So the VF Page can be accessed from any of the records related to the Document record. The issue I am running into is how to set the return URL. I can set the Return URL ID based on each related record but how can I tell which record the user just accessed the VF Page from?
Hyperlink formula: HYPERLINK("/apex/AttachDoc?id="& Id &"&retURL=%2F"& Lead__r.Id ,"Upload Docs Here","_self")
So the formula above would only return the user to the Lead, but what if they actually accessed the link from the Opp or one of the other custom objects?
Tuur Dutoit 13Tuur Dutoit 13
So, if I understand correctly, you have a related list of Document records on the Lead, Opportunity, etc. pages. I don't really understand where this hyperlink is displayed, though. Is this a formula field on Documents (one for each record), or a button on the whole related list?
If it's a formula field, I don't think this is possible: the URL is created once, saved in the Document record and then simply shown on different pages. It is not customized based on the page it appears on.
If it's a button on the related list, I think this is possible using a formula along the lines of:
URLFOR($Page.AttachDoc, [id=Document.Id, retURL=$CurrentPage.URL])