+ Start a Discussion
Michael Clarke 16Michael Clarke 16 

custom list controller for custom records parent-child

I am on the record page for Plant__c object and wanting to customised the list for the child Plant_In_Zone__c object with a vf page.

How do I build the custom list controller? The below code won't save/compile - unexpected token PIZs line 3 (for a start).
public class listPIZCustomController {

    public ApexPages.StandardSetController PIZs
        get{
            if(PIZs==null){
                PIZs = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT Id, Plant__c, Layer__c, Name, Plant_Name__c, Common_Name__c, Zone__c, Zone_Name__c FROM Plant_In_Zone__c 
                    WHERE Plant__c=:apexPages.currentPage().getParameters().get('Id')]));
            }
            return PIZs;
        }
    
    	set;
   }

    public List<Plant_In_Zone__c> getPIZs() {
        return (List<Plant_In_Zone__c>)PIZs.getRecords();
    }
}

 
Abhishek BansalAbhishek Bansal
Hi Michael,

There is syntax error in your code, please try the below code
public class listPIZCustomController {

    public ApexPages.StandardSetController PIZs {
        get{
            if(PIZs==null){
                PIZs = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT Id, Plant__c, Layer__c, Name, Plant_Name__c, Common_Name__c, Zone__c, Zone_Name__c FROM Plant_In_Zone__c 
                    WHERE Plant__c=:apexPages.currentPage().getParameters().get('Id')]));
            }
            return PIZs;
        }
    
    	set;
   }

    public List<Plant_In_Zone__c> getPIZs() {
        return (List<Plant_In_Zone__c>)PIZs.getRecords();
    }
}

Let me know if you need any further help on this.

Thanks,
Abhishek Bansal.
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790
Phone: +917357512102​​​​​​​