function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sforcegarrett7sforcegarrett7 

Recent Child Records from Related Lists in a Page

Hi all,

 

I am wondering if anyone has developed a visualforce page that shows the most "recent" child record in the related list and "rolls it up" on the parent?  I know that can be qualified in many ways but the admiistrator could modify the query to return whatever results make sense.

 

For example...this trigger helps to generate the proper list of records:

http://boards.developerforce.com/t5/Apex-Code-Development/Recent-record-from-related-list/td-p/320385

 

The query in the case of the trigger above is:  [Select Status, LeadId, Id, CreatedDate, ContactId, CampaignId From CampaignMember ORDER BY CreatedDate DESC Limit 5]

 

Taking a step further it would be nice to be able to have a small visualforce page on the parent record to see the returned results rather than having to create a custom field.  I would also like to be able to do this for several objects.  So show me the most recent Campaign the Contact is a member of, show me the most recent closed Opportunity by Close Date, etc.  Sort of like a snapshot on the Contact record instead of having to reference each of the related lists.

 

Sort of like this only backwards:  http://sfdc2u.blogspot.com/2013/05/retrieving-parent-record-from-child.html

https://success.salesforce.com/answers?id=90630000000gpahAAA

 

Any thoughts or ideas appreciated...!