Activity Forums Salesforce® Discussions How to use the Helper class in Salesforce Apex Trigger? 

  • How to use the Helper class in Salesforce Apex Trigger? 

  • Arun

    Member
    January 28, 2020 at 1:19 pm

    How to use the Helper class in Salesforce Apex Trigger?

  • krati vishnoi

    Member
    January 28, 2020 at 1:29 pm

    Hi Arun,

    You can Use Helper Class in Trigger. Your Helper Class is an Apex Class only, by using inside the helper class create a method which can be used by different trigger or different trigger event. You just need to pass the your trigger. new or trigger.old value in the method parameter.

    For Example, here same method is getting called for different trigger events.

    if(trigger.isInsert || trigger.isUpdate){
    
       HelperClass.accountTotalAmountAfterInsertOrUpdateOrDelete(trigger.new);
    }
    if(trigger.isDelete){
       HelperClass.accountTotalAmountAfterInsertOrUpdateOrDelete(trigger.old);
    }
    
    // Helper Class
     public static void updatePrimaryContactAfterDelete(List<Contact> listOfContacts){
      // your code here
    }

     

  • Dharmendra

    Member
    September 23, 2021 at 9:57 am

    How to use Static Helper Classes in Exception Handling?

Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos