7

I've got a number of old apex classes that I am planning up updating to use a more recent version of the Salesforce.com API. Of course, it would be better still if I could retire some of these classes. I know they haven't been updated in years. Is there a way to determine when the class was last run? I don't see anything like a "Last run" property when I edit one of the Apex class views. Is this information available anywhere else (like maybe Eclipse)?

edited to add The metadata API does not even have "date last modified" for an Apex class. "Date last run" was too much to hope for.

2

There is no log maintained by Salesforce around apex execution by default. If you wanted to find out this information in the future I would suggest building something in your system which tracks such information. Which should be quite straight forward. Here are the steps.

  1. Create a custom object to log this information, it could have fields such as : apex class name, running user etc.

  2. Create a utility class / method which makes an entry into this custom object : //Sudo code Public static LogClassExecute(string ClassName, string UserID) { customobject_c newEntry = new customobject_c; newEntry.className = ClassName; // and so on... }

  3. In all the classes you want to log ... Include the call to utility class as the first line in the constructor. (About this point, there is a better way to do this ... Which is use an abstract class design pattern. Which all the apex classes inherit from)

  • I was hoping I would not have to change the code to find out if it was in use, but I do have a logging utility class I can adapt for this purpose. – Jagular Sep 23 '14 at 16:47

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.