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
PmathurPmathur 

Query is either selecting too many fields or the filter conditions are too complicated.

Hi,

 

I am getting error "Query is either selecting too many fields or the filter conditions are too complicated." while running my code.

 

My code is where I getting this error is :

 

List<Sim_CaseReportHistory__c> caseRepHisList = [Select id, TotalQueueTime__c, TotalWorkTime__c, Field_API_Name__c, Owner_Type__c, Actual_Owner_Is_User__c, Case_number__c
from Sim_CaseReportHistory__c where Case_Number__c in : caseNumSet and Is_Migrated__c=true and Field_API_Name__c='Owner'
and CreatedDate__c>=:Sim_Util.getActualStartDateTimeObject(dCurrentDate) and CreatedDate__c<=:Sim_Util.getActualDateEndTimeObject(dCurrentDate)];

 

Any suggestion? Please rply.

 

Eugene NeimanEugene Neiman

Break it up into two (or possibly three) calls.  For example, you might try building a set of IDs

 

Set<ID> intSet = new Set<ID>();

 

and populate with 

 

Select id  from Sim_CaseReportHistory__c where Case_Number__c in : caseNumSet and Is_Migrated__c=true and 

Field_API_Name__c='Owner'

 

Then on a second pass you can pick up

 

Select id, TotalQueueTime__c, TotalWorkTime__c, Field_API_Name__c, Owner_Type__c, Actual_Owner_Is_User__c, Case_number__c
from Sim_CaseReportHistory__c where id in :intSet and 

CreatedDate__c>=:Sim_Util.getActualStartDateTimeObject(dCurrentDate) and
CreatedDate__c<=:Sim_Util.getActualDateEndTimeObject(dCurrentDate)

 

The big decision is decide which condition (Case number set or created date constraint or ?) will return the fewest id's and use that to populate the set.

 

Abhi_TripathiAbhi_Tripathi

 Whatever the corrections i have done u can check that....and can u just tell me why u were using created two times??

    If u want to use it the use OR between the Created date.    

 

  List<Sim_CaseReportHistory__c> caseRepHisList = [Select id

                                                                                                                     , TotalQueueTime__c

                                                                                                                     , TotalWorkTime__c

                                                                                                                     ,  Field_API_Name__c

                                                                                                                     , Owner_Type__c

                                                                                                                     , Actual_Owner_Is_User__c

                                                                                                                     , Case_number__c
                                                          FROM Sim_CaseReportHistory__c

                                                         WHERE Case_Number__c in : caseNumSet AND

                                                                         Is_Migrated__c=true AND              

                                                                         Field_API_Name__c= '' AND

                                                                         CreatedDate__c>=:Sim_Util.getActualStartDateTimeObject(TODAY()) ];

 

THE S!LENT Guardian...!!!.. 

PmathurPmathur

Hi,

 

I tried these things but the main issue is I think is "Set" which I am using in query. It's containing more than 2500 data thats why I think I am facing this problem.

 

Thanks

Abhi_TripathiAbhi_Tripathi

hey,,

yes u can try that also, instead of list go for the sets...

 

Thanks