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
Mitesh SuraMitesh Sura 

bulkify field.getDescribe?

is there a way to bulkify field.getDescribe?

 

for(Schema.SObjectField sfield : fieldMap.Values()){
  schema.describefieldresult dfield = sfield.getDescribe();
  if(dfield.isCalcualted()){ 
    //some code
  } 
  else {
    //some code
  }
}

 

I just want to bypass formula fields for certain sObject. If the object has more than 100 fields, this will fail. What are my options?

Ashish_SFDCAshish_SFDC

Hi, 

 

What is the error that you are getting while running this code - which governor limit is it hitting?

 

Regards,

Ashish

Mitesh SuraMitesh Sura
Ashish,

I am building dynamic SOQL query and since we cannot do "Select * from.." I am pulling all the fields and creating the query.

One of our customer had more than 100 formula fields and error was "Query is either selecting too many fields or the filter conditions are too complicated."

I looked at this article and Bob mentions it may be due to too many formula fields. http://boards.developerforce.com/t5/Apex-Code-Development/Query-is-either-selecting-too-many-fields-or-the-filter/td-p/296245

Hence I wanted to bypass the fields and see if that works.

Does that help? Thank you for your time.
Ashish_SFDCAshish_SFDC

Hi, 

 

Internally SOQL is Converted to SQL. Because of this difference this results in hitting the SQL limit of 64k via Apex whereas we don't via the API (57K).

 

The solution here is to break up the query (or reduce the columns retrieved and only get only the required fields which is always best practice).


You can try something like break up by X number of fields via the describe and merge the resulting lists back into one.


This would be more scalable than us increasing max SOQL.

Note: We say SOQL length can be up to 10K but the real limit is the SQL 64K 

 

Regards,

Ashish

 

Mitesh SuraMitesh Sura
Ashish,

I will look at the code to see if I can reduce the columns.

I am not sure if "breaking up by X number of fields" will work, because it is still part of same transaction.

Thank you for your inputs.