[SalesForce] Problem with “id” parameter on page with apex:relatedList

I have a simple Visualforce page that has the following:

<apex:page standardController="Account">
   <apex:outputField value="{!Account.Name}"/><br />
   <apex:relatedList subject="{!Account.Contacts}" list="AccountContactRoles"/>
</apex:page>

When I navigate to the page it gives me the following error.

Unable to Access Page

The value of the "id" parameter contains a character that is not
allowed or the value exceeds the maximum allowed length. Remove the
character from the parameter value or reduce the value length and
resubmit. If the error still persists, report it to our Customer
Support team. Provide the URL of the page you were requesting as well
as any other related information.

I am specifying a valid Account ID in the URL:

https://c.na14.visual.force.com/apex/contacts?id=001d000000VtORJ 

When I remove the <apex:relatedList> the page renders with the Account Name correctly.

Is there some other parameter or value that I need for the <apex:relatedList> when used with a child? I don't ever remember needing anything else.

I'm in a DE that is Winter '13.

Best Answer

My error...what I really wanted was the related list of each contact. Something like the following:

<apex:page standardController="Account">
       <apex:outputField value="{!Account.Name}"/><br />
       <apex:repeat value="{!Account.Contacts}" var="contact">
           <apex:outputText value="{!contact.Name}"/>
           <apex:relatedList subject="{!contact}" list="AccountContactRoles"/>
       </apex:repeat>
</apex:page>

I was incorrectly specifying a List as the subject, when I needed an object.

Related Topic