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
PalakPalak 

SOQL reteiving 250 records only.

Hi all,

 

I am reteiving list of contact using SOQL query. I want to fetch all the contacts of a particular record type. This query is always returning 250 records. Though there are existing thousands of record.

 

Please help me

 

With regards

Palak Agarwal

steve456steve456

Do u have a limit on SOQL for it be only 250

 

Limit 250 

 

 

Please check or else post your query we can see further

PalakPalak

Hi steve, thanks for your reply,I tried following snippet in debug log. 

 

"

list<id> ids = new list<id>();
//List<contact> con = [select id,name,recordtypeid,Candidate_Summary__c,Candidate_Write_Up__c,General_Competency__c,IT_Competency__c,Skill_set__c,Other_Competency__c from contact where recordtypeid = '0120000000096owAAA' ];
for(contact con1 : [select id,name,recordtypeid,JCandidate_Summary__c,Candidate_Write_Up__c,General_Competency__c,IT_Competency__c,Skill_set__c,Other_Competency__c from contact where recordtypeid = '0120000000096owAAA' limit 2000])
{
ids.add(con1.id);
}
system.debug('testing by ks'+ids.size());

"

 

NOTE :  All the fields except id,name are long text area fields.

 

1). If I will exclude all long text area fields, query is returning all the records around 50000.

2).If query is executed before for statement, as shown(Comented query) it returns only 250 records.

3).If query is executed with for statement, then it works for 2000 records only not more than that. After 2000 records, it starts throwing error "Response to EXEC to /_ui/common/apex/debug/ApexCSIAPI was : -1, transaction aborted".

 

I don't understand why query is behaving in four three different ways.

 

Please help me, 

With Regards

Palak

Mayur Pardeshi 1Mayur Pardeshi 1

You will be not able to fetch more than 250 records if your query contains long text fields. for this, I've implemented this solution. this is working for me.

Solution :

List<PeriopIT_Menu_Fact__c> acc1 = [Select  id
                                                               from PeriopIT_Menu_Fact__c 
                                                               WHERE Account__c = '001S000001BQElxIAH' 
                                                               LIMIT :lim OFFSET :off];
result.accRecord =  [     Select  id,
                                     Internal_ID__c,
                                     Orp_Name__c,
                                     Internal_ID_Text__c,
                                     Datasource_Dim__c,
                                     Aliases__c,
                                     CPT_Codes__c,
                                     External_ID__c,
                                     AORN_Code__c,
                                     IMO_Lexical_Code__c,
                                     IP_Only__c,
                                     IP_Only_CPT_Codes__c,
                                     Non_IP_Only_CPT_Codes__c
                                     from PeriopIT_Menu_Fact__c WHERE IP_Only__c != NULL AND Id in: acc1 LIMIT :lim OFFSET :off];

Previous Code:

result.accRecord =  [     Select  id,
                                     Internal_ID__c,
                                     Orp_Name__c,
                                     Internal_ID_Text__c,
                                     Datasource_Dim__c,
                                     Aliases__c,
                                     CPT_Codes__c,
                                     External_ID__c,
                                     AORN_Code__c,
                                     IMO_Lexical_Code__c,
                                     IP_Only__c,
                                     IP_Only_CPT_Codes__c,
                                     Non_IP_Only_CPT_Codes__c
                                     from PeriopIT_Menu_Fact__c WHERE IP_Only__c != NULL LIMIT :lim OFFSET :off];