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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.