Code Project

Link Unit

Friday, August 03, 2012

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


I get the following error when I try to replicate the custom object: Query is either selecting too many fields or the filter conditions are too complicated.

Even a simple query like Select * from SalesForce...Object was also returning same error.



Reason
This error is from the salesforce.com server and occurs when the table has too many formula fields for the salesforce server to return query results. Internally at the salesforce server, when a query occurs the select list is modified and the calculated fields are replaced with their formulas. Then the sf server tries to execute it and determines that the query is too complex.
 
Solution
You could try using a feature of DBAmp called Column Subsets which allow you to replicate subsets of columns of a table and then glue them together locally. This effectively decreases the number of formula fields in the query. See Column Subset Views in Chapter 2 of the DBAmp doc.

exec sf_replicate 'SALESFORCE','Object_ColumnSubsetAM'
exec sf_replicate 'SALESFORCE','Object_ColumnSubsetNZ'


and then use following to construct the table

Select column1,column2,column3 into Object
from Object_ColumnSubsetAM AM
inner Join Object_ColumnSubsetNZ NZ on AM.id = NZ.id

Alternatively, you can just construct multiple select statements yourself with subsets of the columns.
Post a Comment