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
rashrash 

Too many fields describes: 11

We are currently facing the following  error in the visualforce page:
System.Exception: Too many fields describes: 11
I assume this  is because
Schema.SObjectType.Features__c.fields.getMap(); is getting called multiple times and exceeding the VF limit.
I tried using  Describeresult instead of getMap.
For Example: Schema.DescribeFieldResult F = Account.AccountNumber.getDescribe(); 

But the Object and the field name has to be dynamic in our case.  I need to know if theres any way where we can pass the object and field dynamically in the DescribeFieldResult statement .

So could anyone suggest some solution to this problem?
Best Answer chosen by Admin (Salesforce Developers) 
prageethprageeth

You may be  describing the sobject inside a loop(ex:- 'For loop'). If so put that part outside the loop and retry.

You can use the 'Database.query()' part inside the loop.

All Answers

prageethprageeth

You may be  describing the sobject inside a loop(ex:- 'For loop'). If so put that part outside the loop and retry.

You can use the 'Database.query()' part inside the loop.

This was selected as the best answer
NaishadhNaishadh
As of now, you can not call describe method on more than 10 fields in visualforce page.
Anu-SFDCAnu-SFDC

Hi,

 

Can you plz explain  me more..

 

Here is my part of code..

 

 

 schema.describefieldresult dfield;

Map <String, Schema.SObjectField> fieldMap = Schema.SObjectType.Opportunity.fields.getMap();
for(Schema.SObjectField sfield : fieldMap.Values()){
dfield = sfield.getDescribe();
Pair field = new Pair();
field.key = dfield.getname();
field.label = dfield.getLabel();
field.fieldname = dfield.getname();
field.val = dfield.getDefaultValueFormula();
fields.add(field.label);

if(field.fieldname== 'npe01__Contact_Id_for_Role__c'){
field.val =contactId;
opt.put(field.fieldname,field.val);
}
}

 

 

But, I got too many field describes..

 

Can any one help me out..

 

Thanks

Anu