You need to sign in to do that
Don't have an account?

Trigger Handler Patterns
HI,
what is trigger handler pattern in salesforce and could u give some examples on it.
Regards,
Rajesh.
You need to sign in to do that
Don't have an account?
HI,
what is trigger handler pattern in salesforce and could u give some examples on it.
Regards,
Rajesh.
Hi,
There's no defined pattern as such but it is always considered as a best practice to have all your trigger logic inside one handler class and only have one trigger on each object.
Example Trigger
An Apex Trigger should be written so that every operation calls a method in an external Apex Class. By doing so code can easily be added or removed, and variables can be used multiple times without additional queries to the database.
Example Trigger Handler Class
The Apex Trigger template above calls a handler class to execute the trigger logic, the trigger handler class should be defined as follows:
source: http://macscloud.com/salesforce-apex-triggers-the-definitive-guide/
Hope this helps :-)
All Answers
Hi,
There's no defined pattern as such but it is always considered as a best practice to have all your trigger logic inside one handler class and only have one trigger on each object.
Example Trigger
An Apex Trigger should be written so that every operation calls a method in an external Apex Class. By doing so code can easily be added or removed, and variables can be used multiple times without additional queries to the database.
Example Trigger Handler Class
The Apex Trigger template above calls a handler class to execute the trigger logic, the trigger handler class should be defined as follows:
source: http://macscloud.com/salesforce-apex-triggers-the-definitive-guide/
Hope this helps :-)
Hi,
Thanks for ur reply.
I also consider like this only but for confirmation I asked.
Once again thanks.
Thanks,
Rajesh.
see also - http://developer.force.com/cookbook/recipe/trigger-pattern-for-tidy-streamlined-bulkified-triggers which is one that I have used in many projects