1

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 ?

  • Could you use the Developer Console Query Editor, and export from there? – Robs Nov 15 '18 at 19:44
1

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/

Src: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_describe.htm

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.

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.