+ Start a Discussion
joseph keuler 1joseph keuler 1 

Field Level Triggers - are they possible?

Is it possible to execute a trigger on a field by itself instead of an object?  

ObjectA.Field1  on update of Field1 run trigger.  On update of ObjectA.Field2 do nothing.
Best Answer chosen by joseph keuler 1
joseph keuler 1joseph keuler 1
No this is not possible in any way. you can write a trigger only on sObject.

OR 

You would write the trigger on the object, and if you only want logic to be executed if a certain field has changed, you can compare the new and old values of that field and act accordingly                     
 

All Answers

joseph keuler 1joseph keuler 1
No this is not possible in any way. you can write a trigger only on sObject.

OR 

You would write the trigger on the object, and if you only want logic to be executed if a certain field has changed, you can compare the new and old values of that field and act accordingly                     
 
This was selected as the best answer
joseph keuler 1joseph keuler 1
trigger fieldOnly on Account (before update) {
    for (Account a : Trigger.new) {

    // Access the "old" record by its ID in Trigger.oldMap
    Account oldAccount = Trigger.oldMap.get(a.Id);

    if (oldAccount.Name != a.Name) {
        // do something
    }


}