I am trying to write a class that will list all custom Visualforce components in an .org on a page.

I see that my custom components are included in the component reference at https://myorg.salesforce.com/apexpages/apexcomponents.apexp

But I would like to get the list of just custom components programatically so I can display them on a custom page. Does anyone know how to do this? What I should query or how else I can go about it?


You can query the ApexComponent Object documented here

Here is the sample query for same

[SELECT ApiVersion,ControllerKey,
  MasterLabel,Name,NamespacePrefix FROM ApexComponent]

I executed in execute anonymous to see if this also runs in apex and it does work

system.debug('Result'+[SELECT ApiVersion,ControllerKey,ControllerType,Markup,MasterLabel,Name FROM ApexComponent]);
  • 1
    This trick also works for other types of code as well. It's a great way to find stuff by way of Apex Code. – sfdcfox Apr 15 '16 at 17:16
  • 1
    Awesome, thanks, works like a charm. I know it seems like a simple question, but there are so many things I Google and just can't find the documentation for what I want...... – ScottH7a9 Apr 15 '16 at 17:25

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.