I'm poking around, writing a Python script to fetch ".reportType" XML files for all ReportTypes in an org and then do various things to those files.
First up is figuring out what tables they include.
By parsing the raw XML file, I'm able to easily get output that looks like this:
Schools_with_Applicants.reportType:
4 table(s)
['School__c', 'School__c.FancyPackage__Contacts__r.FancyPackage__Applications__r.Transcripts__r', 'School__c.FancyPackage__Contacts__r.FancyPackage__Applications__r', 'School__c.FancyPackage__Contacts__r']
And I can see from poking around the web user interface that there is indeed:
- a lookup field to the "FancyPackage__Appli__c" object on the "Trscpt__c" object with a Namespace Prefix of FancyPackage and a Child Relationship Name of Transcripts
- a lookup field to the "Contact" object on the "FancyPackage__Appli__c" object with a Namespace Prefix of FancyPackage and a Child Relationship Name of Applications
- a lookup field to the "School__c" object on the "Contact" object with a Namespace Prefix of FancyPackage and a Child Relationship Name of Contacts
What I actually want as output is:
Schools_with_Applicants.reportType:
4 table(s)
['School__c', 'Trscpt__c', 'FancyPackage__Appli__c', 'Contact']
That way, it'll be easy to quickly figure out all reports that use the"FancyPackage__Appli__c" so that when we need to quickly add/remove fields from all such reports, it's not such guesswork. (Not to mention, I can probably script editing the XML from there.)
Question is, what's the simplest way, over various APIs Salesforce provides, to get the data I need to do this translation?
I'm sure I could download the XML for every single object in my org, then parse it, setting aside relevant details from lookup & master-detail fields I find therein. But that seems like a lot of overhead.
Is there a less messy interface I'm not familiar with?