1

I have created a visualforce page which contains a related list and i have placed the visualforce page in the standard layout as a section and the problem i have here is, when i click on the create new button or view, edit etc links the navigation happens within the visualforce section but i want it to function like it does in the normal related list section (which is to redirect the user to that page).

<apex:page standardController="Contact">
  <apex:relatedList list="Sub_Contact__r" />
</apex:page>

Using the below mentioned line in the visualforce page does the trick partially.When i click on the view record link it opens in the same window, but when i click on the edit or delete link the record opens in the same window but once after i save or cancel the edited record it takes me to the visualforce page where i get to see only the related record section without even header or sidebar.

<base target="_parent"/>

2 Answers 2

1

Please add base tag with target="_parent" to open the links in the same window instead in the vf section

<apex:page standardController="Contact">
    <base target="_parent"/>
  <apex:relatedList list="Sub_Contact__r" />
</apex:page>
2
  • Thanks. This does the job partially. When i click on the view record link it opens in the same window, but when i click on the edit or delete link the record opens in the same window but once after i save or cancel the edited record it takes me to the visualforce page where i get to see only the related record section without the header or sidebar.
    – Ean
    Commented Mar 2, 2017 at 10:18
  • Also When i click on the create new record which is present above the related list it opens within the visualforce page section.
    – Ean
    Commented Mar 2, 2017 at 10:19
1

If you create a related list with <apex:relatedList the buttons/links won't work as a normal related list. This is a known issue. Please check this idea link.

There are some workarounds available like changing the button links through JavaScript. You have to compare the generated button/link code with normal related list button/link code in browser developer console and change it based on the required behavior.

Check these below links to get more details about similar approach.

  1. http://salesforce-stuff.blogspot.in/2011/11/visualforce-related-list-button.html
  2. VisualForce apex:relatedlist - button redirection
3
  • Thanks for providing the details. I am able to use custom button with javascript enabled to accomplish my needs. The only thing i need now is to somehow redirect the page back to parent record incase of edit/delete of related list. As of now after edit or delete the user is redirected to the visualforce page which i created with only related list to be shown.
    – Ean
    Commented Mar 2, 2017 at 12:19
  • Try using retURL parameter to return to the parent object.
    – Saroj Bera
    Commented Mar 2, 2017 at 12:23
  • Where should i be using the retURL parameter?
    – Ean
    Commented Mar 2, 2017 at 12:34

You must log in to answer this question.

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