If you’re a Salesforce Admin who wants to become a Developer, you’re in the right place. You already know objects, fields, and automation — now let’s add one more tool: Apex triggers.
⚡ This tutorial will guide you through writing your first Apex Trigger inside the Salesforce Developer Console — no prior coding required!
Why Learn Apex Triggers?
- They allow you to go beyond what Flows and Process Builder can do
- You gain more control over logic and bulk updates
- It’s the first step to becoming a full Salesforce Developer
Step 1: Open Developer Console
Log into your Salesforce Org (Dev Org or Sandbox).
- Click on your avatar (top-right corner)
- Select Developer Console

Step 2: Create a New Trigger
- Go to File > New > Apex Trigger
- Enter the name
SetAccountType
- Select sObject: Account
- Click Submit
Step 3: Write Your Trigger Code
Replace the default code with:
trigger SetAccountType on Account (before insert) {
for (Account acc : Trigger.new) {
if (acc.AnnualRevenue > 1000000) {
acc.Type = 'Enterprise';
}
}
}
Step 4: Save and Test
Click File > Save or use Ctrl + S
.
Now create a new Account record from the UI with an Annual Revenue over 1 million — it will auto-tag the Account Type as “Enterprise”!
Explanation
before insert
: The trigger runs before the record is savedTrigger.new
: Refers to the list of new records being insertedacc.Type = 'Enterprise';
: Sets the field value directly in Apex
How ChatGPT Can Help You Learn Apex
As a beginner, writing code can be intimidating. But with ChatGPT, you have a 24/7 assistant to guide you. Here’s how:
- 🧠 Explain code line-by-line
Ask:Explain what Trigger.new means in Apex
- 🛠 Fix your errors
Paste the error and ask:Why is my trigger failing with 'null pointer exception'?
- 🔄 Convert Flows to Apex
Ask:Can you convert this flow logic into Apex?
- 📚 Practice and exercises
Ask:Give me 3 beginner Apex trigger challenges
Think of ChatGPT as your personal Salesforce coding buddy — it won’t replace practice, but it will definitely accelerate your journey.
Why This Small Trigger Is a Big Deal
This tiny trigger teaches you how to:
- Write real Apex code
- Understand logic and looping
- Build something more flexible than Flow
It’s your first step toward becoming a true Developer!
Next Steps
- Try the same logic on Opportunities or Contacts
- Use
after insert
to trigger external logic - Explore writing Apex classes and test methods
- Use ChatGPT to explain things whenever you’re stuck
Final Thoughts
Don’t wait to become a Developer. Start small. Experiment. Break and fix things.
The more you try, the more confident you’ll get. And now with ChatGPT in your toolbox — you’re never truly stuck.
💬 Follow me for more simple Apex tips, Admin-to-Dev learning guides, and practical ChatGPT use cases in Salesforce!
#Salesforce #AdminToDev #Apex #ChatGPT #SalesforceDeveloper #Trailblazer #LearnToCode
Leave a Reply