You need to sign in to do that
Don't have an account?
Custom Related List - Several layers deep
Hello, everyone. I'm fairly new to VF, and think I can do what I'm about to ask, but wanted to make sure before I went too far on it.
I've built a few new 'profile' objects off of account. On my second layer of 'profiles', I'd like to display a related list of all account contacts. Somewhat like this:
Account -< Contact
^
Profile Summary
^
Config Profile ** -> This is where I'd like a related list that simply shows all account contacts
After reading through the forums quite a bit, it looks like I could possibly create a Controller that would query for account contacts (I think I can create a wf to copy the account id down to the config profile). Once I had the records, I could create a pretty simple vf related list that shows the fields I'm interested in.
This post looked the closest to what I'm thinking of doing: http://boards.developerforce.com/t5/Visualforce-Development/Filter-Data-of-a-Related-List/m-p/95329/highlight/true#M6270
Could someone please let me know if this isn't too crazy? Thanks in advance.
Thanks for the offer, Alok. I've run out of time on this request, so instead have decided to go with an intersection table between my custom object and Contacts. Unfortunately, this means that users need to link each contact one-by-one to the object to get it to show in the related list, but it seemed to be the best answer if not the prettiest. I'm still not quite sure I could even do this in vf, but thank you for the suggestions.
All Answers
Hi Mark,
You can use one of visualforce tag to display relatedlist. You need to have account id in order to display contact realted list.
So just access the account recordid in controller and bind in page like given below -
<apex:relatedList subject="{!id}" list="Contacts"/>
Whatever id you provide in "subject" property that tag display contact related list for supplied account id.
Thanks, Alok, I've tried this but am somewhat stuck. I was able to pull down the Account Id key, but whenever I try to use "Contacts" as the list (or "Contacts__r" or "Contacts__c") it keeps telling me it is not a valid relationship for my new custom object. Is there a way to reference up the hiearrchy, like "Accounts__r.Contacts__r" or something similar?
Hi Mark,
can you please post your code so that can figure out what the problem in actual..?
Thanks for the offer, Alok. I've run out of time on this request, so instead have decided to go with an intersection table between my custom object and Contacts. Unfortunately, this means that users need to link each contact one-by-one to the object to get it to show in the related list, but it seemed to be the best answer if not the prettiest. I'm still not quite sure I could even do this in vf, but thank you for the suggestions.