function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
emuelasemuelas 

Custom controller -return list

Hi ,

 

iam trying to write a custom controller  as below but i get the folowing error in the highlighted line:

 

Error: Compile Error: Return value must be of type: SOBJECT:Product_Serial__c at line 12 column 13

 

 

How do i return a list from the controller?

 

Please help!

 

public class iresv {
list<Product_serial__c> pserial=new list<Product_serial__c>();

public iresv(){

pserial=[select id, name from product_serial__c where product__c in (select product__c from order_line__c where id =
                       :ApexPages.currentPage().getParameters().get('id'))];

}

 public Product_serial__c getSerial() {
            return pserial;
      }

      public PageReference save() {
            update pserial;
            return null;


}
}

Best Answer chosen by Admin (Salesforce Developers) 
Imran MohammedImran Mohammed

Make this change,

 

 public List<Product_serial__c> getSerial() {
            return pserial;
      }

All Answers

Imran MohammedImran Mohammed

Make this change,

 

 public List<Product_serial__c> getSerial() {
            return pserial;
      }

This was selected as the best answer
emuelasemuelas

Worked perfectly! Thank you Imran!