I'm trying to get relationshipName for standard childobject to build dynamic query. Is there any function that returns the queryable name of the standard sObject for SOQL query. Example : Contact->Contacts // ActivityHistory -> ActivityHistories

2 Answers 2


You can use DescribeFieldResult class getRelationshipName() method to dynamically obtain relationship name for any lookup field (standard or custom).


Have a play with the Workbench, particularly the functionality under the info tab. You can see fields, relationships and also use the Queries tab to prepare and try out SOQL and SOSL.

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .