7

You can see global methods in the managed package classes via Web UI. I have hundreds of managed package API classes that I need to search through by a keyword, to find a method that does what I need (or to know if there is even one like that).

Normally I run a full-text search of the Salesforce project in the IDE when I need to find something, but this does not work with managed classes, as their code in IDE is completely hidden, it's not even importing the global method definitions.

Any advice? I really would rather not spend hours opening each API class manually in the web UI whenever I need to find something.

  • 2
    Not an answer per-se, but potentially useful: I see from your comment on a deleted answer this is about the c2g namespace prefix, better known as FinancialForce accounting. I'll note there's web-based API documentation at developer.financialforce.com/technical-reference – ca_peterson Apr 30 '14 at 1:54
7

I have just been playing with the tooling API and discovered that it would be possible to retrieve the global method names for Apex classes within a managed package.

You could write a script that first queries all managed Apex classes (classes that have a namespace - there might be a better way to do this?):

https://SALESFORCE_DOMAIN_HERE/services/data/v28.0/tooling/query/q=SELECT+ID%2C+NamespacePrefix+FROM+ApexClass+WHERE+NamespacePrefix+%21%3D+null

And then retrieve the symbol table for each of these classes:

https://SALESFORCE_DOMAIN_HERE/services/data/v28.0/tooling/sobjects/ApexClass/CLASS_ID

Response will contain a symbol table with global method names/types, properties etc which should look something like:

...
"SymbolTable": {
    "constructors": [],
    "externalReferences": [],
    "innerClasses": [],
    "methods": [ 
        ...
    ],
    "namespace": "NS",
    "properties": [
        ...
    ]

You could parse this to output a nice list that could serve as the documentation you are after.

Sorry that I haven't pieced together all of the puzzle. If you think that you would like to continue down this path I can work with you towards a proper solution.

| improve this answer | |
  • 1
    I was toying with this too. I'm probably going to make it into a VF page... It's too useful not to. – sfdcfox Apr 29 '14 at 22:50
  • Yes, although it looks like one would need to do a separate callout for each ApexClass in order to retrieve all of the symbol tables. I wonder if there is a more efficient way of achieving this? – luke.mcfarlane Apr 29 '14 at 23:56
  • @sfdcfox You might be interested in the Apex Tooling API, this blog has an example of querying the Symbol table using SOQL, the example is for a specific class but can be used to return multiple. andyinthecloud.com/2014/03/17/… – Andrew Fawcett Apr 30 '14 at 11:22
  • @luke.mcfarlane You can actually retrieve the Symbol Table as part of your first query, just include it as a field in the select, thus you will get a list back of all symbol tables for selected classes, SELECT ID, SymbolTable, NamespacePrefix FROM ApexClass WHERE NamespacePrefix ... Note that in the documentation it states that this results in a demand compile if things are not in the salesforce cache for example, if you get a timeout you can try again or i typically just ensure the user does a Compile All Classes before trying again from the Apex Class page. – Andrew Fawcett Apr 30 '14 at 11:27
  • That's nifty. I can use that directly in the code I deleted, I suppose... – sfdcfox Apr 30 '14 at 16:50

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.