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
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.