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
Rafael.Martins.SantosRafael.Martins.Santos 

What is handler and how does it works?

Hi All,

I'm trying understand how the handler works but I don't understand yet.

I want know what is handler and how does he works?

is there exist some document that explain how is it work step by step?

Thanks
Rafael.
Amit Chaudhary 8Amit Chaudhary 8
Handler is nothing just a apex class. Where you can write your code and call other method in some order. Please check below post for trigger handler class
1) http://amitsalesforce.blogspot.com/2015/06/trigger-best-practices-sample-trigger.html

Let us know if this will help you
Rafael.Martins.SantosRafael.Martins.Santos
Hi Amit thanks for your reply,

let me make one more questions.

I have at least 4 trigger for the same object that execute a @future and call a web service method.
With this handler process, can I have only one trigger that execute 4 methods @future at same time?

For example I have to create 3 records in another system, so the trigger must execute 3 methods at same time. is it work?

Thanks
Amit Chaudhary 8Amit Chaudhary 8
For you question . Yes you can control all in single trigger for all 4 future method.

As per trigger best pratice we should write only one trigger at a time because in mutliple trigger you can not control which one should execute first.
But with handler class you can control it.

 
Rafael.Martins.SantosRafael.Martins.Santos
Hi Amit,

Thanks, I gonna test here and I let you knowif works.

Best Regards
Rafael