4

We are trying to automate certail processes for which we need to find the dependent components for a Class/Page/Trigger.

We understand that salesforce is providing dependent components using "Show Dependencies" button when respective components are viewed but is there a way to get these programatically?

(This was posted in Stakeoverflow and got the response to use SymbolTable and look for external references - https://stackoverflow.com/questions/27367493/how-to-find-dependent-components-for-a-class-page-trigger-using-api-tooling-or)

I tried following steps to access SymbolTable.

  1. Created a Connection
  2. Created a MetadataContainer using POST (Tooling API) with Name as Compile.
  3. Queried MyPageController class, got the Id, Name and Body from ApexClass.
  4. Created ApexClassMember using POST (Tooling API) with MetadataContainerId set to the id from Step 2, ContentEntityID set to class id from step 3, Body set to body from step 3.
  5. Created ContainerAsyncRequest to compile the class with MetadataContainerId set to id from step 2 and IsCheckOnly to true. (Tried false also). The compilation was successful as the response State is 'Completed'.
  6. After successful compilation, tried querying ApexClass for SymbolTable, I am getting the data but not ExternalReferences. (We should query ApexClassMember to access SymbolTable, not the ApexClass)

When I check the same class in developer console, I am able to see the 4 related components, 1 Apex Page and 3 Classes.

Am I doing anything wrong, unable to figure out what mistake i am doing. Any pointers is much appreciated.

Thanks!

Code: https://github.com/bugude/SalesforceDeveloperOrgRespositories/blob/master/TestSymbolTable.java

4
  • Without the code, the answers you get will be less specific. Can you post the relevant sections of your code here?
    – Jagular
    Commented Dec 23, 2014 at 16:07
  • Hi All, Please help me on this. I am not sure what mistake I am doing and I am stuck here.
    – Bugude
    Commented Dec 29, 2014 at 19:18
  • Do you know a way to find references for other metadata components, like Lightning Component, FlexiPage, Layout, Object?
    – Patlatus
    Commented Dec 4, 2018 at 13:16
  • I have a related question salesforce.stackexchange.com/questions/241353/…
    – Patlatus
    Commented Dec 4, 2018 at 13:16

1 Answer 1

2

The issue was with the final query, I was querying ApexClass instead od ApexClassMember to access the SymbolTable. Once I have queried ApexClassMember after compiling, it was successful.

One thing though, it does not give the extends class in SymbolTable.

1
  • One observation is, I could successfully access SymbolTable in Developer Org but was not able to access it in Sandbox. Are there any specific permissions to be enabled at org level?
    – Bugude
    Commented Jan 6, 2015 at 19:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .