You need to sign in to do that
Don't have an account?
Listing rows in a table via a lookup relationship.
Hi
Trying to write my first VisualForce page.
I have a custom object called "Invoice_Header__c". I have another custom object called "Nominal_Detail__c". The nominal detail has a field called "Nominal_Detail__c.Invoice_Header__c" which is a lookup to the "Invoice_Header__c" object. It's not a Master-Detail relationship
I'm trying to desing a page that gives me a pdf to print out and can't work out how to display a table showing all the rows in "Nominal_Detail__c" for a selected record in "Invoice_Header__c". This is where I've got to, but it won't save:
<apex:page renderAs="pdf" standardController="Invoice_Header__c" >
<apex:relatedList list="Nominal_Detail__r" />
<p>This is my new page: invoicepdf</p>
<p>Fields for Account details to go here...</p>
<apex:pageBlock title="Nominal Analysis">
<apex:pageBlockTable value="{!Nominal_Detail__r}" var="nom">
<apex:column value="{!nom.Code__c}"/>
<apex:column value="{!nom.Invoice_Detail_Amount__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Will this only work with Master-Detail relationships, or can I get a list for items linked by a lookup?
David
Normally you'd use the relatedList component to display a related list. I've not used the __r notation, but I think that you can only traverse from child to parent that way, rather than retrieve a list.
I've found that if the relatedList isn't suitable, I end up retrieving the sobjects I'm interested in via a method in the controller.