Salesforce Developer Tutorial: How to Implement a Trigger Framework

preview_player
Показать описание
In this video we go over how to implement a trigger framework in your salesforce environment and why you would ever care to do it. Learning how to do this will make your life much easier as a Salesforce Developer.

Follow all of our social media here:

Salesforce development books I recommend:

----------------------------------------------------------------------------------------------------------------------------------------

Table of Contents:

0:00 - Intro
0:26 - Why use a trigger framework?
3:35 - The trigger framework I like to use.
6:06 - How to use the trigger framework.
22:42 - Demoing the trigger
25:45 - Outro

DISCLAIMER: The views and ideas expressed on this YouTube channel and blog are based on past development experiences and may not always work for your particular scenarios. The advice in these videos may also become outdated as technology advances. They should be used as examples for educational purposes only. Using any shown solutions in your own org is not advisable since they are example scenarios.

#salesforce #salesforcedeveloper #salesforceadmin
Рекомендации по теме
Комментарии
Автор

For some reason I just kept wanting to say, "Trigger Handler Framework" in this video... It's just a "Trigger Framework". I'm sorry my brain just couldn't stop feeding me those words. It's just a Trigger Framework.

CodingWithTheForce
Автор

Thanks, super helpful to see these practices in action. I was given one sample trigger framework before and it had way too many layers of abstraction. Looking forward to more videos like this!

marvtheandroid
Автор

Thank you very much for all your videos. They are very helpful.

iulianachiriac
Автор

Aiight, first of all, thank you for your content! It's of the highest quality compared to the competition in regards to both topics and delivery.

I want to discuss the "Why?" points because I was asked this at an interview, and didn't answer so great repeating the usual stuff that's listed on the web on this topic. So here's my 5 cents.
1. "If you put your logic in the trigger, it becomes hard to unit test that logic." I'm on the fence about this. I don't really have a good argument for it, but I'd rather test DML operations and not trigger handler methods. Kinda because it's closer to the actual use case. As for helper methods - you can use them inside the trigger, with no handler class as a mediator. So there's no difference in that regard whether you put your logic inside the trigger or not, it's a matter of how you organize your tests.
2. Reusability. I find this unrelated. Again, put the reusable parts in helpers/utilities and reference them right inside the trigger. No difference whether you're using a handler or not.
3. Readability (nice, modular, beautiful-looking code). Yep. No objections.

What I don't see mentioned is by using a handler inside a trigger you get to choose system vs user mode. Trigger always executes in system mode, while you can write a with sharing handler, and that's easily an equally important reason as reusability and readability in my opinion.

chethelesser
Автор

Why dont you make a video for how we can use OOPs concepts in apex and best practices in apex with live examples

coolboy
Автор

Great video as always! I still have this confusion, in which scenarios to use Trigger "isBefore" and "isAfter"

marikenafeuereisen
Автор

Very cool. I will look into this for my own projects.

Have you ever used a Logger Framework? Logging has been a pain point with Salesforce and I've wondered if Logger Frameworks could help.

russellcopeland
Автор

Any reason you prefer this framework over one that uses a Custom Metadata setting to control the execution of Apex?

salesforcetutorialsbybill
Автор

The Trigger Framework is perfect for a use case I'm facing. Is there a similar concept of a Validation Rules Framework that I can use to bypass Validation Rules?

russellcopeland
Автор

What if in a scenario where you want to do something in both after insert and after update? would you need to override both afterInsert() and afterUpdate() in the handler?

clydetan