1

This is a documented limit on SOQL parent-child queries: No more than 20 parent-to-child relationships can be specified in a query. You'll have to batch your queries in groups of 20 parent-child relationships.


1

You need : getRelationshipName() in this part of code (it may not worked for you, because you haven't checked it for null value): for (Schema.ChildRelationship cr: obj.getChildRelationships()) { if (cr.getRelationshipName() == null) continue; system.debug('Child Object Relationship Name:'+cr.getRelationshipName()); query = query + '(select Id ...


Only top voted, non community-wiki answers of a minimum length are eligible