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
bhagibhagi 

How to get the 1st 200 records in account object

Hi Everyone,

 

         How to get the 1st 200 records in account object using pagenation

can anyone explain with sample code please..

 

 

Thanks&Records

neeru

Alex.AcostaAlex.Acosta

Use StandardSetController...

 

http://www.salesforce.com/us/developer/docs/pages/Content/apex_pages_standardsetcontroller.htm

 

Set your setPageSize parameter to limit 200 records at a time.

bhagibhagi

Thanx For replay Alex

 

i wrote controller for that its working oppurtinity obj fine..but its not working for account object 

 

can u share some sample code of account obj for that please??

Alex.AcostaAlex.Acosta

should be the same way you did opportunity....

 

ApexPages.StandardSetController ssc = 
new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Name,Id FROM Account]));
ssc.setPageSize(200);
List<Account> accountCollection = (Account)ssc.getRecords();

 

neeruneeru

Thanks Alex now it works fine...i dint found the accept ur solution button..because only i am not marked ur solution sorry for that

 

 

and one more question Alex

 

my need is when i write a componet  and  i call that componet in my visualforce page  it shows objectname(Account) and fieldname(phone) with in the pageblocktable and i use this componet in another object(contact) it will also display like this only...

 

how i pass the values dynamically in components??

 

can you help this scenario with some sample code please??

 

Thanks&Regards

neeru

Alex.AcostaAlex.Acosta

This should give you the proper information...

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_component.htm

 

as far as the attribute you'll be passing it, I would define it as a the instance class for that sObject... IE:

 

<!-- Page: --> 
<apex:page>
    <c:myComponent myRecord="{!Account}" />
</apex:page>

<!-- Component:myComponent -->  <apex:component> <apex:attribute name="myRecord" type="Account" required="true"/> <apex:outputText value="{!myRecord.Id}"/> </apex:component>
neeruneeru

Ya dat's ok alex..dis is my controller i am getting error like unexpected token line 11.....i think i am facing the problem on database.query() in that i am writing a query dat one not executed  ...can you check dis controlle once alex please

 

public class testcon {
public String acon{get; set;}

    // ApexPages.StandardSetController must be instantiated
    
    // for standard list controllers
    
    public testcon(){
    list<Schema.SObjectType> obj = Schema.getGlobalDescribe().Values();
    ApexPages.StandardSetController setCon = new ApexPages.StandardSetController(Database.getQueryL

ocator(
         [SELECT obj.getDescribe().getName() from sObject]));
    }
    
    public ApexPages.StandardSetController setCon {
        get{
            
            
            return setCon;
        }
        set;
    }

    // Initialize setCon and return a list of records
    
    public List<sObject> getacc() {
        return (List<sObject>) setCon.getRecords();
    }
}