Retrieving parent record from child record in Salesforce

Sample Code:

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 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);


No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit