I’ve been using the Dependency API to try to retrieve all dependencies for a given metadata.
I would like to get a list of dependencies, and then retrieve these with the Metadata API.
Unfortunately, I can’t find an easy way to get the expected Metadata API name from the MetadataComponentId returned from the Dependency API.
For instance, with the following Dependency API results:
Both fields (RefMetadataComponentName) have the same name, but not the same Id: they are fields from separate sObjects.
So the related name expected by the Metadata API would be the following:
How can I get this from the MetadataComponentId ?
I tried to use the Tooling API to query directly a table with the same name as the MetadataComponentType (quite naive, right ?):
Select DeveloperName from CustomField where Id = 'xxxx'
This doesn’t work because some tables have a
DeveloperNamefield, some other will have a
FullName, anyway nothing is consistent.
Moreover, I’m not getting the parent sObject name, just a
TableEnumOrIdfield, and it looks like you need another query to get the sObject name.
Also, some other RefMetadataComponentType doesn’t exist as Tooling API tables (NavigationMenu, ListView, StandardEntity…).
In this specific example, I also tried to query
FieldDefinition, but while I tried to field on
RefMetadataComponentId, I didn’t get any result (not easy to understand which Id is the same as which one).
Have I any other solution than to hardcode everything for each MetadataComponentType:
– which table to query (maybe more than 1)
– which query to use
– hardcode a few other stuff (add
__cat the end of a custom field, after of course finding a way to know if the field is custom or not).