0

Working for pagination on custom object record, using StandardSetController everything initialized but it is giving error that

Error: Compile Error: Unexpected token 'return'. at getAgentAsset Method

Controller code

public class PaginationController{
   Public Integer size{get;set;} 
   Public Integer noOfRecords{get; set;} 
   public List<SelectOption> paginationSizeOptions{get;set;}

public PaginationController(){
    size=10;
    paginationSizeOptions = new List<SelectOption>();
    paginationSizeOptions.add(new SelectOption('5','5'));
    paginationSizeOptions.add(new SelectOption('10','10'));
    paginationSizeOptions.add(new SelectOption('20','20'));
    paginationSizeOptions.add(new SelectOption('50','50'));
    paginationSizeOptions.add(new SelectOption('100','100'));
}

public ApexPages.StandardSetController setCon {
    get {
        if(setCon == null) {                
            setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                  [select Firstname__c,Lastname__c,Primary_AgentID__c,spg__c,CloseDate__c, from Agent_Asset__c where isActive__c = true order by createddate desc]));
            setCon.setPageSize(size);  
            noOfRecords = setCon.getResultSize();
        }            
        return setCon;
    }
    set;
}

public PageReference refreshPageSize() {
     setCon.setPageSize(size);
     return null;
}


public List<Agent_Asset__c > getAgentAsset() {
     return (List<Agent_Asset__c >) setCon.getRecords();
 }
}

1 Answer 1

0

Compiler is complaining as you have an extra comma in SOQL query before FROM; while querying the standard controller's data:

setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
    [select Firstname__c,Lastname__c,Primary_AgentID__c,spg__c,CloseDate__c, 
    from Agent_Asset__c where isActive__c = true order by createddate desc]));

If you are not already using VScode, I would recommend to do so as it has good error highlighting:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .