You need to sign in to do that
Don't have an account?

Issue with too many field describes error
Hi,
I have an organization that has more than 100 custom objects. I need to loop through these objects and check if the object includes a specific field. As I'm doing this I hit the governor limit of field describes. I don't believe that I'm doing a field describe but it thinks I am. Here is my code that gets executed for each object (sObjectDescribe):
Map<String, SObjectField> fieldMap = sObjectDescribe.fields.getMap(); List<SObjectField> fieldValues = fieldMap.values(); for(SObjectField fieldValue:fieldValues) { String fieldValueStr = String.valueOf(fieldValue); if (fieldValueStr.endsWith('__Special_Field__c') || fieldValueStr == ('Special_Field__c')) { return true; } }
When I look at the documentation it talks about the sObjectDescribe.fields.getMap() call as follows:
The value type of this map is not a field describe result. Using the describe results would take too many system resources. Instead, it is a map of tokens that you can use to find the appropriate field. After you determine the field, generate the describe result for it.
So, what am I doing wrong here? Is this a bug or documentation bug?
Thanks!
Try this and let me know if that help......
Hi,
I tried this but it didn't make a difference. Thanks for the suggestion though.
Can we have the Error along with rest of the code ?
The error is as follows:
Too many fields describes: 101
The code is as follows:
I can run a unit test on the above code and the field describe limit is consumed as many custom objects I have in the org. I tried it in different orgs and got the same result. In an org where we have more than 100 custom objects, this is blowing up with the above error.
Just to test I tried the code below and could hit the limit due to describe in a loop.:
This line of code is counted every time your loop runs:
Map<String, SObjectField> fieldMap = sObjectDescribe.fields.getMap();
I hope that helps....