Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I'd like to be able to pull a listing of Apex classes, triggers, and components that have been created or modified after a certain date. Is there an easy way to do this?

share|improve this question
1  
If you are interested in doing this for reasons of deployment, ASIDE.IO has this type of functionality built into it's deploy (push) screen. –  Phil Rymek Feb 26 at 15:07
add comment

3 Answers

up vote 4 down vote accepted

If your aim is to do something manually as a once-off, you can use the "Query Editor" of the "Developer Console" to run these queries (adding where and order by as required):

Select a.SystemModstamp, a.Status, a.NamespacePrefix, a.Name,
        a.LengthWithoutComments, a.LastModifiedDate, a.LastModifiedById,
        a.IsValid, a.Id, a.CreatedDate, a.CreatedById, a.BodyCrc, a.Body,
        a.ApiVersion
From ApexClass a

Select a.UsageIsBulk, a.UsageBeforeUpdate, a.UsageBeforeInsert,
        a.UsageBeforeDelete, a.UsageAfterUpdate, a.UsageAfterUndelete,
        a.UsageAfterInsert, a.UsageAfterDelete, a.TableEnumOrId,
        a.SystemModstamp, a.Status, a.NamespacePrefix, a.Name,
        a.LengthWithoutComments, a.LastModifiedDate, a.LastModifiedById,
        a.IsValid, a.Id, a.CreatedDate, a.CreatedById, a.BodyCrc, a.Body,
        a.ApiVersion
From ApexTrigger a

for classes and triggers. But I don't think many/any other components are exposed in this way, so you will have to use the metadata API for a general solution.

share|improve this answer
    
This looks like what I was looking for. I figured it had to be stored in a table some place as everything is meta data. I just didn't see those objects in a listing. –  Robert Harper Feb 26 at 19:24
add comment

You have two approaches you can take. One is using the Tooling API and the other is to query for the objects directly in Apex.


Tooling API

You should be able to get this type of information using the Tooling API. Specifically look at ApexClass, ApexTrigger, and ApexComponent. You can essentially pass a query to it (like the example form the documentation):

req.setEndpoint('http://na1.salesforce.com/services/data/v28.0/tooling/query/?q=Select+id,Body,LastSyncDate,Metadata+from+ApexClassMember+Where+MetadataContainerID=\'+ containerID + '\'');
req.setMethod('GET');

Apex

If you need to explicitly do this in Apex, you best bet is to just query for the objects. As with above, you will want to use:

You can then just write a SOQL query with a proper WHERE clause. So something like:

SELECT Id, Name FROM ApexClass WHERE LastModifiedDate > :date
share|improve this answer
add comment

For recently created Pages and Classes

vf page

    <apex:page controller="recent">
      <apex:form >

       <apex:pageBlock title="Recently Created Pages">
         <apex:pageblockTable value="{!pages_creat}" var="page_c">
             <apex:column value="{!page_c.name}"/> 
             <apex:column value="{!page_c.createddate}"/>
            <apex:column value="{!page_c.lastmodifieddate}"/>

         </apex:pageblockTable>
       </apex:pageBlock>

       <apex:pageBlock title="Recently Created Classes">
         <apex:pageBlockTable value="{!apex_class}" var="ap">
            <apex:column value="{!ap.name}"/>
            <apex:column value="{!ap.createddate}"/>
            <apex:column value="{!ap.lastmodifieddate}"/>
         </apex:pageBlockTable>

       </apex:pageBlock>
  </apex:form>
</apex:page>

Controller

public  class recent {

    public list<apexclass>getApex_class() {
        return [select name,createddate, lastmodifieddate from apexclass order by createddate desc limit 10];
    }

    public list<apexpage>getPages_creat() {

        return [select name, createddate, lastmodifieddate from apexpage order by createddate desc limit 10];
    }
  }
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.