+ Start a Discussion
PalakPalak 

Only 200 records are returning On doing pagination.

Hi all,

 

I am returning a list of contact to visualforce page from apex class and have also applied pagination. 

I am using database.queryLocator to accomplish pagination. But  only 200 records are always returning on visualforce, although there exists around 20000 records. Please can anybody help me on this, its urgent.Any help would be appreciated.

 

With Regards

Palak Agarwal

bob_buzzardbob_buzzard

Can you clarify what you mean by applied pagination?  If you are using a standard list controller, I think that's intentional - you are paginating through the data from the controller, rather than the controller having all the records and just returning a few at a time.

PalakPalak

Hi 

 

Thanks for replying. Following is the snippet that is used for pagination

"

  con1 = Database.query(OrderQuery); // list of  contacts

Integer pag = Integer.valueOF(25);

con27 = new ApexPages.StandardSetController(con1);
system.debug('test my code : '+pag);
con27.setPageSize(pag); "

 

 

 

But  this code is returning maximum of 200 records though there are 23000 records on contact. Please help me to retrieve the remianing contacts on the visualforce page.

 

With Regards

Palak Agarwal

 

bob_buzzardbob_buzzard

According to the docs for the standard controller:

 

 

--- snip ---

 

  • The maximum value for the optional scope parameter is 2,000. If set to a higher value, Salesforce chunks the records returned by the QueryLocator into smaller batches of up to 2,000 records.

  • If no size is specified with the optional scope parameter, Salesforce chunks the records returned by the QueryLocator into batches of 200.

 

--- snip ---

PalakPalak

How can I specify the scope?

bob_buzzardbob_buzzard

Ah - you are using query rather than query locator - sorry about that.  In that case it should manage the full list you pass it.

 

What does your query look like?

PalakPalak

I am creating a dynamic soql query on contact and then passing it into database.query(). 

bob_buzzardbob_buzzard

Yeah, I figured that.  Can you post an example of the generated query?

PalakPalak

Hi below is the example of the query

 

Select js_country2__c,js_gmtrj_jobs_notified_old__c,jigsaw_clean__last_sync__c,js_gmtrj_candidate_short_list__c,js_gmtrj_candidate_summary__c,spectate__recentpageview1__c,jigsaw_clean__duplicate__c,jigsaw_clean__jigsaw_id__c,role__c,fcms__profile_manager_name__c,otherphone,isdeleted,sf4twitter__twitter_bio__c,recordtypeid,js_gmtrj_duplicate_criteria__c,systemmodstamp,sf4twitter__twitter_location__c,otherstreet,hasoptedoutofemail,jigsaw_clean__graveyard__c,state2__c,js_gmtrj_other_competency__c,jigsawcontactid,sf4twitter__twitter_follower_count__c,js_gmtrj_jobs_applied__c,js_city1__c,js_country3__c,othercity,js_gmtrj_home_email__c,lastmodifiedbyid,js_gmtrj_notes_comments__c,your_reason1__c,date_of_call__c,js_state3__c,js_gmtrj_birthday__c,js_gmtrj_current_pay__c,your_reason3__c,js_gmtrj_background_check__c,lastname,lastcurequestdate,jigsaw_clean__fresher__c,mailingcountry,spectate__recentpageview2__c,sf4twitter__influencer_type__c,fcms__registration_approved__c,department_2__c,gmtrc_torque_email_opt_out__c,js_gmtrj_other_email__c,gmtrj_state__c,js_gmtrj_pager__c,js_gmtrj_candidate_id__c,firstname,rpaas_current_job__c,sf4twitter__twitter_username__c,jigsaw_clean__duplicate_id__c,assistantname,jigsaw_clean__silent_update__c,js_gmtrj_skill_matched__c,spectate__recentactivity3__c,js_jobs_applied_old__c,rpaas_visa_status__c,js_gmtrj_phone__c,js_gmtrj_veteran_status__c,js_city3__c,city2__c,country3__c,jigsaw_clean__automatic_updates__c,js_gmtrj_referral_relationship__c,js_company_name1__c,sf4twitter__languages__c,js_country1__c,lastactivitydate,js_gmtrj_online_profile_link__c,js_gmtrj_internal_candidate__c,jigsaw_clean__jigsaw_created_date__c,description,js_gmtrj_target_bill_rate__c,js_date_comm_freq_changed__c,js_gmtrj_is_duplicate__c,js_gmtrj_preferred_job_term__c,js_company_name3__c,fax,js_gmtrj_languages__c,sf4twitter__twitter_image_url__c,js_gmtrj_percentage_of_travel__c,js_your_reason2__c,js_gmtrj_job_title__c,alternate_email__c,email,js_gmtrj_general_competency__c,donotcall,jigsaw_clean__jigsaw_sync_activity__c,rpaas_title__c,rpaas_meets_preconditions__c,js_gmtrj_country__c,js_state2__c,mailingstate,js_gmtrj_cell_phone__c,sf4twitter__fcbk_image_url__c,jigsaw_clean__sync_status_indicator__c,js_gmtrj_parse_resume_migration_id__c,department,js_gmtrj_availabilty_to_interview__c,js_gmtrj_recruiter__c,sf4twitter__fcbk_profile_url__c,js_gmtrj_referral_date__c,lastmodifieddate,js_company_name2__c,js_gmtrj_isrequired__c,js_video_link1__c,name,js_gmtrj_video_resume_link__c,accountid,jigsaw_clean__crm_last_modified__c,js_gmtrj_notify_candidate__c,js_gmtrj_department__c,sf4twitter__research_this_contact__c,sf4twitter__twitter_following_count__c,sf4twitter__origin__c,company_name1__c,otherpostalcode,company_name3__c,mailingpostalcode,js_gmtrj_time_zone__c,company_name2__c,spectate__lastactivityat__c,city1__c,js_gmtrj_jobs_notified__c,video_link1__c,jigsaw_clean__jigsaw_managed_backend__c,js_gmtrj_work_status__c,js_gmtrj_desired_pay_type__c,rpaas_location_preference__c,state1__c,jigsaw,leadsource,jigsaw_clean__sync_status__c,js_gmtrj_referral_source__c,reason__c,createdbyid,sf4twitter__influencer__c,password__c,js_send_news_letter__c,genius_com__genius_hard_bounce__c,assistantphone,skype4sf__skype_name__c,js_gmtrj_cover_letter__c,rpaas_status__c,js_gmtrj_experience__c,sf4twitter__follow_status__c,js_gmtrj_previous_titles__c,js_video_link3__c,createddate,ownerid,video_link2__c,canallowportalselfreg,js_gmtrc_db_pro_email_opt_out__c,rating__c,jigsaw_clean__jigsaw_managed__c,rpaas_current_employer__c,js_your_reason1__c,js_gmtrj_location_1st_choice__c,js_gmtrj_account_name__c,username__c,sf4twitter__twitter_last_tweet__c,department_3__c,js_gmtrj_previous_employer__c,js_username__c,js_gmtrj_update_skills__c,reportstoid,gmtrc_db_pro_email_opt_out__c,sf4twitter__level__c,js_gmtrj_desired_pay__c,genius_com__genius_hard_bounce_date__c,rpaas_current_location__c,sf4twitter__twitter_creation_date__c,fcms__profile_manager_email__c,jigsaw_clean__automatic_updates_disabled__c,sf4twitter__fcbk_username__c,js_role__c,state3__c,mobilephone,title,js_gmtrj_available_to_start__c,js_your_reason3__c,country2__c,js_gmtrj_education__c,js_gmtrj_it_competency__c,emailbounceddate,gmtrj_email_opt_out__c,mailingstreet,js_gmtrj_home_email_c__c,homephone,js_gmtrj_resume_received_date__c,emailbouncedreason,fcms__portalemailalert__c,sf4twitter__twitter_picture__c,jobs_applied__c,jigsaw_clean__sync_status_summary__c,fcms__username__c,sf4twitter__followed__c,genius_com__geniusscore__c,bounced_email__c,js_gmtrj_open_for_relocation__c,js_gmtrj_candidateid__c,js_gmtrj_work_details__c,salutation,js_gmtrj_email_opt_out__c,rpaas_source__c,phone,otherstate,your_reason2__c,js_gmtrj_resume_source__c,spectate__pageviews__c,send_news_letter__c,contact_status__c,jigsaw_clean__jigsaw_last_modified_date__c,jigsaw_clean__jigsaw_sourced__c,js_gmtrj_street_address__c,rpaas_current_salary__c,sf4twitter__fcbk_user_id__c,hasoptedoutoffax,req_no__c,lastcuupdatedate,spectate__recentactivity2__c,fcms__company_name__c,fcms__cmsprofile__c,js_gmtrj_candidate_status__c,js_gmtrj_gender__c,js_skill_matched__c,city3__c,js_gmtrj_postal_code__c,fcms__password__c,id,js_gmtrj_candidate_write_up__c,contact_type__c,country1__c,spectate__recentpageview3__c,js_gmtrj_ethnicity__c,birthdate,js_gmtrj_margin__c,spectate__createdat__c,js_gmtrj_locations_2nd_choice__c,js_gmtrj_city__c,js_communication_frequency__c,sf4twitter__twitter_user_id__c,sf4twitter__contact_source__c,sf4twitter__twitter_status_count__c,masterrecordid,rapleaf__rapleafinfo__c,sf4twitter__fcbk_picture__c,js_gmtrj_job_category__c,js_video_link2__c,communication_frequency__c,spectate__recentactivity1__c,js_gmtrj_skill_set__c,js_gmtrj_confirmation__c,video_link3__c,jigsaw_clean__jigsaw_last_sync_locked__c,rpaas_start_prference__c,js_gmtrj_education_details__c,othercountry,js_gmtrj_fax__c,js_city2__c,js_state1__c,mailingcity from contact where recordtypeid='0120000000096owAAA' and accountId ='00100000004zsQ1AAI' And id not in : keys AND id in:cids Order by name asc
bob_buzzardbob_buzzard

Hmm.  Do you really have 23,000 contacts matching that query?  Seems like a lot to be associated with a single account.

PalakPalak

Yes there are, I have run a report to check the actual number of records and that gave around 23000 records, matching the same query.

bob_buzzardbob_buzzard

If you debug the list as soon as you have executed it, does it show 200 there (i.e. is it the query only returning that many or the controller doing something odd once it takes over)?

PalakPalak

Yes query is returning 200 records.

bob_buzzardbob_buzzard

Have you tried running the query in the developer console, to remove the controller from the picture.

PalakPalak

yes it is returning 200 records only....

bob_buzzardbob_buzzard

That sounds very much like on 200 records satisfy the query.  Are you sure that the report you ran had exactly the same filter criteria?