1

I have a requirement.

I want to get list of visualForce pages that has Account as its standard controller.

Like if any page has started like <apex:page standardController='Account' > Then I need all those page's names.

Thanks in advance.

2

The following apex queries the ApexPage object to get the metadata and then checks to see if the metadata contains standardController="Account".

List<String> pageNames = new List<String>();
for (ApexPage ap : [select Name, Markup from ApexPage]) {
    if (ap.Markup.contains('standardController="Account"')) {
        pageNames.add(ap.Name);
    }
}
System.debug('Found: ' + pageNames);

Not that the Apex pages I was looking for use double quotes rather than single quotes around the object name. Your Visualforce pages may be different.

0

You are going to have to use the Metadata API for this requirement. Visualforce pages are revealed through the API as ApexPages, and you can receive the base64 encoded page content from a SOAP call (Depending on version, this will be either asynchronous or synchronous). Once you decode this information into a string, you will be able to search the page contents to determine if this page uses the specified controller.

Heres a reference to the ApexPage Metadata object, as well as an excellent example of using the metadata API from apex.

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.