2

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?

1 Answer 1

3

You can query the ApexComponent Object documented here

Here is the sample query for same

[SELECT ApiVersion,ControllerKey,
   ControllerType,CreatedById,CreatedDate,Id,Markup,
  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]);
2
  • 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
    Commented Apr 15, 2016 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
    Commented Apr 15, 2016 at 17:25

You must log in to answer this question.

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