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
MWorldMMMWorldMM 

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

I am running a series of queries to provide audit data to a client who wants on-demand snapshots of all the fields on a set of related objects. Everything runs fine except that for one object I receive 'System.UnexpectedException: Query is either selecting too many fields or the filter conditions are too complicated.'

 

The queries are all identical in structure and very simple (ie SELECT field 1, field2, ... fieldn FROM object WHERE Related_Object_Id = Id.) What is really odd is that the object we have this error with is NOT the largest object we are reporting on (by about 20%). SInce these queries are built dynamically using Schema.SObjectType.<object_Name>.fields.getMap(), trimming out columns would be messy, not to mention contrary to the clients needs.

 

Any ideas of why this could be happening? And what I can do to fix it? Is there a documented limit on the number of columns allowed in a query?

 

 

QueOraQueOra

Yes, I encountered same. I don't think it will be acceptable to remove some of columns to make this work - as we wanted to take a snapshot of all data in the system. Any ideas?