function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Miguel Gonzalez 4Miguel Gonzalez 4 

Adding 'Handler' class to currently working Trigger on After Insert action

I have a working Apex trigger that is set to fire whenever someone tries to edit an existing case's FTP Actions field.  Here is the coding as it stands now:
trigger UpdateFTPCases on FTP_Action__c (after insert) {
    List<Case> updtCases = new List<Case>();
    
    for(FTP_Action__c f : Trigger.new){
        //After Insert trigger area
        if (f.FTP_to_Case__c != null && f.Action_Date_Time__c != null) {
            updtCases.add(new Case(
                Id = f.FTP_to_Case__c,
                Last_Upload__c = f.Action_Date_Time__c));
                }
        }
            if (!updtCases.isEmpty()) {
            update updtCases;
    }   
        
}

This trigger has been tested and unit tested and works fine.  My manager would like to see if we can add in a Handler class and adjust the code as necessary.  This is just us playing around with Triggers and there are no plans to use these in production.  Being written for Sandbox use only.
sfScottsfScott
It sounds like you're asking about a trigger framework to help make managing the trigger code a little easier?  If so take a look at this post:  https://developer.salesforce.com/page/Trigger_Frameworks_and_Apex_Trigger_Best_Practices

There's also a cookbook for this as well:  http://developer.force.com/cookbook/recipe/trigger-pattern-for-tidy-streamlined-bulkified-triggers

Hope this helps!
James LoghryJames Loghry

My favorite trigger framework (along with a few other MVPs) is Kevin O'Hara's framework. https://github.com/kevinohara80/sfdc-trigger-framework.  Like others, it forces you to write your trigger logic in separate Apex classes.  Additionally, the framework has built in hooks for recursion checks, running on before and after update, etc.  Check it out.