Skip to content

Instantly share code, notes, and snippets.

@shanerk
Created May 18, 2020 19:50
Show Gist options
  • Save shanerk/38648262665500d4e7a479188e843110 to your computer and use it in GitHub Desktop.
Save shanerk/38648262665500d4e7a479188e843110 to your computer and use it in GitHub Desktop.
Gets list child relation API names based on the child object type (Salesforce Apex)
// Gets list child relation API names based on the child object type (Salesforce Apex)
//
DescribeSObjectResult type = SobjectType.Account;
String filter = 'Feed';
for (ChildRelationship relation : type.getChildRelationships()) {
if (String.valueOf(relation).contains(filter))
system.debug('* ' + relation.getChildSObject() + ' = ' + relation.getRelationshipName());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment