You need to sign in to do that
Don't have an account?
creemej
Why does this sample code violates the ChildRelationship Governor Limit = 10
Hi,
I try to understand this Governor Limit (from apex_language_reference/winter'09):
You can only use 10 getChildRelationships method calls per sObject during the execution of an Apex script.
For example, an Apex script can execute 10 getChildRelationships method calls for Account, then another 10 for Lead. For more
information about governor limits, see Understanding Execution Governors and Limits on page 142.
I read: 10 for Account, 10 for Contact, 10 for Contract ... but not 10 for ALL !!!
Is there a way to do something dynamicaly?
Thanks,
creemej
Schema.DescribeSObjectResult r;
List<Schema.ChildRelationship> childRelationships;
//Account
r = Account.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Account.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Account.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Account.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
//Contact
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
//Contract
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
I try to understand this Governor Limit (from apex_language_reference/winter'09):
You can only use 10 getChildRelationships method calls per sObject during the execution of an Apex script.
For example, an Apex script can execute 10 getChildRelationships method calls for Account, then another 10 for Lead. For more
information about governor limits, see Understanding Execution Governors and Limits on page 142.
I read: 10 for Account, 10 for Contact, 10 for Contract ... but not 10 for ALL !!!
Is there a way to do something dynamicaly?
Thanks,
creemej
Schema.DescribeSObjectResult r;
List<Schema.ChildRelationship> childRelationships;
//Account
r = Account.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Account.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Account.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Account.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
//Contact
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
//Contract
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
Is this normal or is this a bug?
Schema.DescribeSObjectResult r;
List<Schema.ChildRelationship> childRelationships;
r = Account.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contact.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Contract.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Lead.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Case.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Solution.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = User.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Idea.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Asset.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Opportunity.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();
r = Partner.SObjectType.getDescribe();
childRelationships = r.getChildRelationships();