Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have read documents for StandardSetController, but I don't understand what it is or why to use it.

share|improve this question
up vote 3 down vote accepted

ApexPages.StandardController (documentation) encapsulates just a single Sobject (e.g. Account, Opportunity).

ApexPages.StandardSetController (documentation) contains a list of records (one or more), and has additional functions to facilitate pagination (moving between pages) and updating a number of records at once.

For example in test class when we initialize

ApexPages.StandardController

Account objAccount = [SELECT Name FROM Account LIMIT 1];
ApexPages.StandardController standctrl = new ApexPages.StandardController(objAccount ); 

ApexPages.StandardSetController

List<account> accountList = [SELECT Name FROM Account LIMIT 20];
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(accountList); 
share|improve this answer
    
suppose in ApexPages.StandardController i will change limit 1 to 20 then whats type of effects change. Account objAccount = [SELECT Name FROM Account LIMIT 20]; ApexPages.StandardController standctrl = new ApexPages.StandardController(objAccount ); – Vipin Indora Mar 1 at 6:52
    
@VipinIndora first your query will return list so you need to assign to List<Account> lstAccount and in new ApexPages.StandardController(lstAccount[0]); .. You need pass single record.. Beacuse if you check the documentation StandardController accept only one record.. – Ratan Mar 1 at 6:54
    
yes @Ratan Thanks – Vipin Indora Mar 1 at 7:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.