First, I don't have anything to post as far as code, because nothing has worked even remotely so far. I've written several extensions that allow me to 'look down' to child data (for instance, all the Campaign Members associated with the current Contact), but I have a new request, and I'm not sure how to proceed.

We have an object called IssuingFirm__c. It has two child objects called Issue__c and Filing__c. I need to be able to return data from all three objects to a visualforce page that starts at the Issuer__c object.

I can use the Standard controller to get the data from Issue__c, and query the data on the IssuingFirm__c record using relationships, but I'm not sure how to go 'up' to the IssuingFirm__ and then back down to Filing__c.

Any guidance, or a link to documentation that will help is appreciated.


Perhaps this documentation will help you better understand.

This should be fairly straightforward with Apex. Making some assumptions about your relationship names.

public with sharing class IssueExtension
    public Issue__c issue { get; private set; }
    public IssuingFirm__c firm { get; private set; }
    public List<Filing__c> filings { get; private set; }
    public IssueExtension(ApexPages.StandardController controller)
        if (!Test.isRunningTest()) controller.addFields(new List<String> {
        issue = (Issue__c)controller.getRecord();
        firm = [
                (SELECT Id FROM Filings__r)
            FROM IssuingFirm__c
            WHERE iD = :issue.IssuingFirm__c
        filings = (firm.Filings__r == null) ? new List<Filing__c>() : firm.Filings__r;
  • Although mine is very similar, I still can't seem to get the returns I expected. Maybe I'm overthinking it. I'll start again and use your template as reference. Thank you for responding. Once it works, I'll make sure to mark it as an answer.
    – HomerJ
    Mar 27 '15 at 18:46
  • So things are working (thanks again @AdrianLarsen) but one last question. I've not used the IF block you show above, and I'm curious what the intent is?
    – HomerJ
    Mar 27 '15 at 21:16
  • If you are not referencing that field on the page, the controller will not query for it.
    – Adrian Larson
    Mar 27 '15 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.