I am using Workbench to show the Child Relationships of objects. Is there any way to have Workbench export that into a spreadsheet ? I'm able to do that when I run a query on records, so I'm wondering if there is some kind of way of doing it for that as well ? Is "Child Relationship" an object I can query ?
1 Answer
No, workbench cannot export that detail as CSV,Its not exactly the flat data structure rows like sobject records.ChildRelationShip isn'[t an object that you can querry. The data is stored in Tree-like data structures.
Can we do something via code to get it done?
Yes, lets see how workbench querries the relationship fields
Workbench makes an API call to Describe Sobject endpoint with Sobject you have selected
Endpoint :
/services/data/v43.0/sobjects/Account/describe/
You can write a code that calls that endpoint and parse that JSON, and create CSV of the relationship fields and attach to a record/email you back.
Other way would be to use the Apex Sobject describe.
List<Schema.ChildRelationship>accChildRelationships =Account.SObjectType.getDescribe().childRelationships;
System.debug(JSON.serializePretty(accChildRelationships));
it will return the List which you can parse and get it sorted.