Ads

Friday, 3 May 2013

Retrieving parent record from child record in Salesforce?


Visualforce Page:

<apex:page controller="sample" >
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!intList}" var="i">
            <apex:column value="{!i.Name}"/>
            <apex:column value="{!i.Member__r.Name}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>


Apex Controller:

public class sample
{   
    public List<Interest__c> intList {get;set;}
    public sample()
    {
        String sql = 'SELECT Name, Member__r.Name FROM Interest__c';
        intList = Database.Query(sql);
    }   
}


Output:

No comments:

Post a Comment