You need to sign in to do that
Don't have an account?
Laurie Drew
Help displaying a Related List
Hi All,
Not sure if this is even possible but here we go...
I have 2 custom objects 'History' and 'Data' that are both children of the Contact object. Is there a way that I can display 'History' as a related list on the page layout for a record in the 'Data' object if both are children of the same contact record? There can be more than one 'History' record and more than one 'Data' but they are always tied back to the parent Contact. I would really appreciate any ideas/help anyone can suggest?
Not sure if this is even possible but here we go...
I have 2 custom objects 'History' and 'Data' that are both children of the Contact object. Is there a way that I can display 'History' as a related list on the page layout for a record in the 'Data' object if both are children of the same contact record? There can be more than one 'History' record and more than one 'Data' but they are always tied back to the parent Contact. I would really appreciate any ideas/help anyone can suggest?
You should not use a related list. Create an extension for data with a list of History where the history contact = data contact. Check this link:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
Your class would look something like this but i dont know your fields:
And then use related history list with an <Apex:pageblockTable>.
Wil,
All Answers
wil,
public class Data {
Map<String, History__c> myMap = new Map<String, History__c>();
for(History__c objDH : [Select H.Id, H.Donated__c, H.Amount__c, H.Date__c From History__c H])
myMap.put(objDH.Name, objDH);
}
But cannot save, receive problem message:
Expecting '}' but was: 'for'
Then I created the following vf page:
<apex:page standardController="Data">
<apex:relatedList list="History__c" subject="{Data.objDH}"/>
</apex:page>
But cannot save, receive problem message
'Formula expression is required for attribute subject in in Data at line 2 column 62.'
Help please??
You should not use a related list. Create an extension for data with a list of History where the history contact = data contact. Check this link:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
Your class would look something like this but i dont know your fields:
And then use related history list with an <Apex:pageblockTable>.
Wil,