12

I want to try to log changes on apex classes in my org. Everytime the apex class is edited by someone i want to log the username and timestamp. Sounds easy but as i tried to write a simple trigger on the ApexClass object i got an error:

Error: Compile Error: SObject type does not allow triggers: ApexClass

This is what i've tried so far without any luck:

trigger myTrigger on ApexClass(after update) {
}

Is there any workaround for this approach?

0
8

Triggers are not allowed on Apex classes. I think the solution here is a behavioral and process one and not a trigger. In my opinion, all code should be kept in some version control system. Changes should be committed, tested and reviewed prior to deploying to production. The advantage of a VCS is the ability to track changes and rollback as needed.

1
8

You can't execute triggers on the ApexClass object. Unfortunately, there is no in-system method for tracking changes. See Apex Code History - Ideas on the Idea Exchange.

1
  • :( I will try to vote – Sergej Utko Oct 15 '13 at 13:26
4

Far from ideal but this can be accomplished by doing your saves with an ant script that also calls a rest endpoint that can query for the change in ApexClass and update some other record.

Alternatively, Aside.io is a Force.com IDE that does what you are seeking, saving the information in Aside_Code_Update__c records. Note: You need to enable "Org Code Search" for this to occur.

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.