Skip to main content
Hi all,

I have two objects in Master Detail relationship.

Ticket__c  is a Master and Ticket_item__c is Child.

I have related list of Ticket_item__c in Ticket__c but it is standard page and it will show only 10 columns.

I want to display the Ticket_item_c list in Ticket Page Layout with 12 columns. 

Can you please point any sample visualfore page on how to write this.  

Thank you
5 answers
  1. Feb 10, 2018, 4:43 AM
    Hi Sunil

    When you perform a child to parent query you have to use Child Relationship Name for child object followed by __r. By default it will be your plural name. You can find this on your child object on field(Master-Detail)..How to perform soql query refer this link https://developer.salesforce.com/forums/?id=9060G000000XbH5QAK

    However Make the code changes 

     

    <apex:page standardcontroller="Ticket__c" extensions = "sample1">

    <apex:pageBlock>

    <apex:repeat value="{!tc}" var="a">

    <apex:pageBlockTable value="{!a.Ticket_Items__r}" var="c">

    <apex:column value="{!c.Name}"/>

    //Here you can write your rese 11 columns

    </apex:pageBlockTable>

    </apex:repeat>

    </apex:pageBlock>

    </apex:page>

     

    public class sample1

    {

    public List<Ticket__c> tc {get;set;}

    public sample1(ApexPages.StandardController controller)

    {

    Id id = ApexPages.currentPage().getParameters().get('Id');

    tc = [SELECT Name, (SELECT Name FROM Ticket_Items__r ) FROM Ticket__c where ID =: id];

    //Please see your child relationship name once in my case it isTicket_Items

    }

    }

     
0/9000