You need to sign in to do that
Don't have an account?

Redirecting to correct VF page
I have a custom object which has lookup relationship with Account and Contact. On the account and contact page I have related list to that object. I have created 2 VF pages to display fields related to this custom object in the format I want. One of the VF page is for users who click on edit/new/view in the related list of the custom object on Account page and other is if the user comes from Contact page.
I'm trying to figure out how to redirect user to a particuar VF page depending on whether they click view/edit/new in the related list on Account or Contact page.
Thanks for help.
I'm trying to figure out how to redirect user to a particuar VF page depending on whether they click view/edit/new in the related list on Account or Contact page.
Thanks for help.
All Answers
thanks,
Kaustav
Step 1. - Override the new button with any one of the VF pages
Step 2. - Add a method in the controller of the VF Page with which you have overriden that checkes the id
Step 3. - Call this from action attribute of the VF page.
<apex:page id="samplePage" ..... action="{!checkSource}">
....your code
</apex:page>
The concept is - when you click the new button on the related list a parameter called the return url is added to the url. You can see from that parameter whether the related list that was clicked was on a contact page (id it starts with 003) or an account page ( id starts with 001). If it is 003 then redirect that user to the contact page.
Note: If the object is exposed through a tab then you also need to keep a handling for that scenario as in that scenario the return url parameter will not be present. If the only way the users can click on the new button of this custom object is through the two related lists then you are okay.
Hope this helps.
Thanks,
Kaustav
VF page name: DispatchPage