
Learn how to automate Salesforce processes with Apex triggers, using before and after events on standard and custom objects. Understand trigger syntax and events like before insert and after update.
Create an apex trigger on the account object with a before insert event, add system.debug messages, and test by inserting an account to review the logs in Salesforce.
Explore trigger context variables such as is executing, is insert, is update, is delete, is before, is after, undelete, and the new and old lists and maps.
Explore before insert and after insert triggers for accounts, updating rating to hot or cold based on industry. Create related opportunities automatically on account insert using trigger.new data.
Explore before update and after update trigger events on account records, updating the description when the phone changes and syncing the new phone to related opportunities.
Implement before delete and after delete scenarios in a Salesforce Apex trigger on the employee object. Prevent deletion of active employees and update the related account's employee count after deletion.
Learn how after undelete fires, undeleting an employee restores records, activates the employee, and updates the account's employee count through a Salesforce apex trigger flow.
Apply before insert, update, and delete on the account to set rating from industry, update description when the phone changes, and block deletes of active accounts with an error.
Update accounts' annual revenue automatically by summing opportunity amounts on after insert, after update, and after delete using an Apex trigger and handler.
Explore database class methods and the addError method in an apex trigger, comparing with DML and implementing try/catch to handle missing fields during account and opportunity creation.
Learn how to prevent recursion in an Apex trigger after update by using a prevent recursion class with a static firstCall flag, so update logic runs only once.
Explore triggers and order of execution in Salesforce, covering declarative and Apex automation, before/after events, validations, flows, duplicate rules, rollup summaries, and post-commit logic.
Explore the Apex test class and the testing framework, learn to write unit tests in a sandbox or development org, and meet 75% code coverage for production deployments.
Learn to create an Apex class and its test class, use the isTest annotation, write test methods, apply System.assertEquals for validation, and review code coverage and test results.
Demonstrates writing positive and negative test cases for an Apex class in Salesforce, using a test class to verify logic and boost code coverage with System.assertEquals.
Create and test Apex classes with sObjects by building accounts and contacts, updating fields, and validating results with assertions to achieve full code coverage.
Learn to write an Apex test class for a trigger, covering insert and update, with trigger handler that copies billing to shipping when a checkbox is enabled, using bulk testing.
Discover how a test utility class enables bulk data creation for Apex tests with a reusable create account records method that returns an account list and supports configurable insert behavior.
Implement a before insert trigger on account creation to set rating to hot when industry is media or energy, with a handler class and a test class for coverage.
Implement a before insert trigger on opportunity to auto-populate the description with 'hot opportunity' when amount is between 100k and 500k, using a handler and a test class for coverage.
Learn to implement a before insert Salesforce apex trigger that copies billing address to shipping address on account creation, guarded by a copy billing to shipping checkbox.
Demonstrates a scenario-based Apex trigger on account after insert to create and link a related contact, with trigger handler and test class ensuring full code coverage.
Demonstrates an apex trigger on account creation that automatically creates a related opportunity via a trigger handler, links by account id, and includes a test class covering bulk inserts.
Create an after insert trigger on case to populate the latest case number on the related account, using a trigger handler and a test class for code coverage.
Explore a hands-on Salesforce Apex trigger scenario that updates the latest opportunity amount on the account after insert, using a trigger handler and a test class.
Learn how to implement an Apex trigger on account creation to auto-create related contacts or opportunities based on two checkboxes, with test coverage for the trigger handler and scenarios.
Implement a before update trigger on account phone changes to update the description with old and new values, and validate the logic with a comprehensive test class for coverage.
Implement a Salesforce Apex trigger and test class to copy billing to shipping on account insert and update, using trigger new and old maps to detect changes.
Implement a Salesforce Apex trigger and test class that automatically sets account rating to hot when industry is media on insert or update, using before insert and before update.
Demonstrates a Salesforce Apex trigger and handler that populate opportunity descriptions on insert and update based on stage, using a common method and a test class for code coverage.
Update related contacts' home phone fields when an account phone changes, using a map-based after update trigger and test class to ensure bulk updates and code coverage.
Demonstrates an after-update Apex trigger with parent-to-child SOQL to update related contacts' home phone when accounts change, comparing map-based and parent-to-child approaches, with test class coverage.
Apply Apex trigger techniques to copy updated account billing address to related contacts' mailing address after update, using map-based and parent-child SOQL approaches, with a test class and best-practice guidance.
Create a trigger and handler to generate a task on an opportunity when the stays field updates, assigned to the logged-in user or owner, with a test class for coverage.
Explore a hands-on Salesforce Apex trigger scenario: update an account from yes to no, automatically convert related opportunities to closed lost, with a test class to verify the behavior.
Demonstrates a before delete apex trigger and handler to block deleting accounts with active set to yes, plus a bulk-ready test class using try-catch to cover custom validation errors.
Use custom labels in Apex trigger and test class to replace hardcoded messages, enabling centralized updates for account deletion alerts when active is yes across trigger and test code.
Implement a before update trigger to prevent updates on accounts created seven days ago, show a UI error, and verify behavior with a test class handling bulk records.
Apply custom validation in a Salesforce Apex trigger before inserting opportunities, enforcing a non-null amount, displaying a UI error, and using a trigger handler and test class with custom labels.
Enforce validation on opportunity updates by implementing a before update trigger and handler to require a close lost reason when stage moves to close lost, with a supporting test class.
This course is designed for Salesforce developers who want to learn about Apex Triggers, Apex Tests, and the power of custom validation in Salesforce. Whether you are a beginner or have some experience, this course will give you a solid foundation in Apex Triggers and help you become an expert.
You will learn how to create Apex Triggers, understand context variables, and master the difference between Before and After events such as Before Insert, Before Update, and Before Delete. You will also learn about the order of execution and how to prevent recursion in your triggers.
The course also covers Apex Tests and how to write positive and negative test cases in a test class. You will learn about sObjects and how to create a test class for your triggers. The course includes scenarios, such as creating related contacts, updating related opportunities, and applying custom validation on opportunity records.
We will cover many industry ready practicals, such as:
Populating the rating as "Hot" on account creation if the industry is Media or Energy
Populating the description on opportunity creation based on the amount value
Copying the billing address to the shipping address on account creation
Creating a related contact on account insertion
Creating a related opportunity on account insertion
Populating the latest case number on account on case creation
Populating the latest opportunity amount on account on opportunity creation
Creating a contact or opportunity based on the user's choice when an account is created
Updating the description on account when the phone field is updated
Copying the billing address to the shipping address on account insert or update
Updating the related contacts on account update using a map or parent-child SOQL
Creating a task on opportunity when the stage is updated
Updating the related opportunity when an account is updated
Applying custom validation in Apex Trigger and using try & catch in the test class
Applying custom labels in Apex Trigger and test class
Preventing the update of accounts created 7 days ago from today
Applying custom validation on opportunity record creation
Applying custom validation while updating an opportunity record
By the end of this course, you will have a strong understanding of Apex Triggers and Apex Tests and be able to apply custom validation in Salesforce. Sign up now and take the first step towards becoming a Salesforce trigger expert!