Getting Started

  • What is Trailhead
  • myTrailhead
  • Trailblazer Community
  • Career Growth

Learn

  • Trails
  • Trailmixes
  • Modules
  • Projects

Credentials

  • Superbadges
  • Certifications
  • Maintain Certifications

Salesforce

  • Salesforce.com
  • AppExchange
  • Developers
  • Help Portal
© 2026 Salesforce, Inc. All rights reserved. Privacy Terms of Use Trust Accessibility Cookie Preferences
SalesforceTrailhead
  • Today
Apex Triggers

Get Started with Apex Triggers

+500 Points~45 minsHands-On Challenge
Apex TriggersGet Started with Apex Triggers

Org:Mindful Goat Playground

Topics

  • Concepts
  • Hands-On Challenge

Looking for help?

Explore Help ResourcesShare Your Feedback
Learning Objectives

After completing this unit, you'll be able to:

  • Write a trigger for a Salesforce object.
  • Use trigger context variables.

Concepts

An Apex trigger runs before or after records are inserted, updated, deleted, or undeleted. Context variables like Trigger.new and Trigger.isInsert tell the code what happened.

Hands-On Challenge

  1. Create a trigger AccountAddressTrigger on Account, before insert and before update.
  2. When Match_Billing_Address__c is true, copy the billing postal code to the shipping postal code.
trigger AccountAddressTrigger on Account (before insert, before update) {
  for (Account a : Trigger.new) {
    if (a.Match_Billing_Address__c) a.ShippingPostalCode = a.BillingPostalCode;
  }
}
Check ChallengeDemo check
Next unit Bulk Apex Triggers