You need to sign in to do that
Don't have an account?
Can we query for Schema inside a for loop
Hello Everyone,
Is it Ok to have Schema statements inside for loop? Will it affect governor limits?
For ex, i want to have some statement like this
for(Employee emp : empList){
String str = Schema.SObjectType.Employee__c.getRecordTypeInfosById().get(Employee__c.RecordTypeId).getName();
}
Thanks & Regards,
B Archana
Is it Ok to have Schema statements inside for loop? Will it affect governor limits?
For ex, i want to have some statement like this
for(Employee emp : empList){
String str = Schema.SObjectType.Employee__c.getRecordTypeInfosById().get(Employee__c.RecordTypeId).getName();
}
Thanks & Regards,
B Archana
No governor limit for schema describe call from Summer'14 release onwards. But it is not a good practice and it will impact performance. Try to get all your schema related details before for loop and store it in MAP and use it.
Reference:
https://releasenotes.docs.salesforce.com/en-us/summer14/release-notes/rn_apex_describe_limit_removal.htm