0

This is my simple VF page named "RelatedListDetail":

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

It´s used to override "New" and "Edit" contact buttons.

enter image description here

Problem is that when i click the "New" button the related list "DealRows" is not showed.It´s showed instead clicking "Edit" button. I suppose this s related to "New" record mode.

Is there a way to always show apex:relatedList?

Thanks in advantage for any advice.

6
  • Are you embedding your VF page into the standard page layout of the Contact object?
    – Force Hero
    Commented Jan 30, 2015 at 12:53
  • No, using the page i m overriding "New" and "Edit" contact buttons.
    – Enry
    Commented Jan 30, 2015 at 12:54
  • Sorry, it shows that in your screen shot - my bad. If you're creating a new Contact there won't be any related records. What are you trying to do ultimately?
    – Force Hero
    Commented Jan 30, 2015 at 12:56
  • Clicking "New" button (on page load) i m inserting a contact record in the apex controller in order to have an ID and let a user add other records "Deal row" in the same page. So i want that the related list will always be showed.
    – Enry
    Commented Jan 30, 2015 at 13:03
  • Ok cool, what I recommend you do is call the function that creates the new Contact from the action attribute in the apex:page tag and have it return a new PageReference('/' + newContact.Id); you might need to do setRedirect(true); on the new PageReference object.
    – Force Hero
    Commented Jan 30, 2015 at 13:06

1 Answer 1

1

Ok cool, what I recommend you do is call the function that creates the new Contact from the action attribute in the apex:page tag and have it return a new PageReference('/' + newContact.Id); you might need to do setRedirect(true); on the new PageReference object.

To clarify, this will create the new Contact and the redirect back round to the same page but in "View" mode rather "New" mode. If you haven't overridden "View" you can always return PageReference('/' + newContact.Id + '/e'); to show the page in "Edit" mode which you have overridden. :)

You must log in to answer this question.

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