For the sake of my programming around this with a makeshift fix:
Is this implying that I am trying to write to more than 100 fields at a time across multiple records..? Or even one record? I can't seem to find a clear definition for this error.
Any help would be appreciated. Thanks.
Attribution to: AMM
Possible Suggestion/Solution #1
Look in the code that you have not done any describe call inside the for loop
Schema.DescribeFieldResult F = Account.AccountNumber.getDescribe();
This is an example for field describe .Search for the describe calls in the code and make sure we have out of the for loop.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_fields_describe.htm
Here is the document of complete list of fielddescribe calls .
There is a limit that in a single context run you can have only 100 fielddescribe calls.This is one of the governor limits of platforms
Here is the class thats causing issue .I see getdescribe inside the for but that may not be issue but please dont call this inside the for loop .Try to bulkify
for(Schema.SObjectField sfield : fieldMap.Values()){
schema.describefieldresult dfield = sfield.getDescribe();
string fname = dfield.getname();
//if (fname.indexOf('pb_') > -1 && fname.indexOf(productName) > -1 )
if (fname == ('pb_Stage_' + productName + '__c') || fname == ('pb_SubStage_' + productName + '__c') ||
fname == ('pb_RecordType_' + productName + '__c') || fname == ('pb_CreateDate_' + productName + '__c') ||
fname == ('pb_Client_' + productName + '__c') || fname == ('pb_CloseDate_' + productName + '__c') ||
fname == ('pb_SubBegin_' + productName + '__c') || fname == ('pb_SubEnd_' + productName + '__c') ||
fname == ('pb_Amount_' + productName + '__c') )
{
if (dfield.isUpdateable())
if (fname == ('pb_Client_' + productName + '__c') )
accObj.put(fname, false);
else
{
accObj.put(fname, null);
}
}
}
return accObj;
As shown above by Andrew Fawcett you may get in map and this should resolve the issue
Attribution to: Mohith Shrivastava
Possible Suggestion/Solution #2
You will likely be using the fields collection. This is the only bit currently still constrained by the governors in this area for some reason. Take a look at, Understanding Apex Describe Information, specifically section Using Field Describe Results
Schema.DescribeFieldResult F = Schema.SObjectType.Account.fields.Name;
The best thing to do is get the full map of fields and store this in a static if you need it from other places in your code.
Map<String, Schema.SObjectField> accountFields = Schema.SObjectType.Account.fields.getMap();
Attribution to: Andrew Fawcett
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/3661