20 Salesforce Trigger Interview Questions with Real-Time Scenarios
Categories:N/A
Last Update:5 October 2026
Publish Date:25 February 2026

Written by
Admin
Reviewed by
Srijan Institute Editorial Team
Srijan Institute Editorial Team
Expert Review Team
This content has been carefully reviewed by the Srijan Institute Editorial Team to ensure accuracy, clarity, and consistency with our editorial standards. Our team evaluates key information and supporting details before publication to provide readers with reliable and relevant content.
✓
Expert Verified
This blog covers 20 essential Salesforce Trigger interview questions with real-time scenarios to help you prepare effectively. It includes practical examples, common use cases, and expert-level explanations for both freshers and experienced professionals.A complete guide to confidently crack Salesforce interviews.

What happens when a Salesforce trigger works for one record but fails when 200 records arrive at once? This real-world challenge can change results fast. Salesforce Trigger interview questions often test bulk processing, Governor Limits, recursion, Flow, SOQL, DML, and common project errors.
Interviewers want to know if you can write secure, scalable, and bulk-safe Apex code for a live Salesforce org. In this blog, you will explore 20 Salesforce Trigger interview questions with clear answers, examples, and real-time scenarios. They will also support broader Salesforce Developer interview questions and coding situations.
What Is a Salesforce Trigger?
A Salesforce Trigger is Apex code that runs by itself when a record changes. For example, you can use a trigger when a record is:
Added
Changed
Deleted
Restored
A trigger can run before or after a record change. Before Trigger runs before Salesforce saves the record, you can use it to check data or change a field before the record is saved. An After Trigger runs after Salesforce saves the record. You can use it when you need the record ID or need to work with other records.
There is one small detail to remember. An after trigger does not mean the whole transaction is finished. It still runs as part of the same transaction.
Top 20 Salesforce Trigger Interview Questions by Experience Level
These Salesforce Trigger Interview Questions and Answers start with the basics. Then they move to harder topics and examples.
If you are new to Salesforce, start here. Learn what a trigger does first. Then learn when to use each trigger type.
Salesforce Trigger Interview Questions for Freshers and Beginners
Q1. What Trigger Events are available in Salesforce?
A. Salesforce has seven trigger events:
before insert
before update
before delete
after insert
after update
after delete
after undelete
Each event runs at a different point. For example, you can use before insert when you need to change a value before a new record is saved. You can use after undelete when a deleted record is restored.
Q2. What Are Trigger.new and Trigger.old?
A. Trigger.new gives you the new record values. Trigger.old gives you the old record values. You can use it during update and delete events. Here is a simple example. An Opportunity changes from Prospecting to Closed Won. you can compare the old Stage with the new Stage. This tells me that the Stage changed.
Interview Questions on Salesforce Triggers for Advanced Level
Q3. What Is Trigger Bulkification, and Why Does It Matter?
A. Trigger Bulkification means writing Apex code that can handle many records at the same time. A trigger may get one record. It may also get 200 records. Your code should work well in both cases. You avoid running SOQL or DML again and again. That can cause Governor Limit errors.
For example, you can collect all Account IDs from Contacts first. Then you run one SOQL query to get the Accounts. You can store them in a Map. Then you process the records and run DML.
The basic flow is simple:
Collect → Query → Process → DML
Q4. How do you prevent trigger recursion?
A. Trigger recursion happens when your trigger runs again because another update starts it. First check what changed and only run the logic when that change needs action.
For example, when an Opportunity moves from Prospecting to Closed Won, you can run your logic when the Stage changes to Closed Won. If another field changes, you do not need to run the same logic.
You can also check if the action has already happened. This helps stop the same work from running twice. A static Boolean can help in some cases. But you would not use it for every recursion problem.
Q5. What are Salesforce Governor Limits?
A. Governor Limits are limits set by Salesforce. They control how many system resources your Apex code can use in one transaction. These limits apply to things like SOQL queries, DML statements, CPU time and other Salesforce resources.
For example, you should not put a SOQL query inside a loop. Why? If your trigger gets many records, the query may run many times. This can hit a Governor Limit and cause an error.
Q6. What is a Trigger Handler class?
A. A Trigger Handler class keeps the main business logic outside the trigger.
This keeps my trigger small and easy to read. For example, your trigger can detect an Account update. It then calls a handler class. The handler checks the rules and does the required work. This also makes my code easier to test and maintain.
Q7. How does Salesforce Order of Execution affect trigger design?
A. Salesforce follows a set order when it saves and updates a record. A trigger is only one part of this process. Other automation can also run. For example, a Flow may update a record. That update can cause Apex trigger code to run again. If you do not think about this, you may get Extra updates, Trigger recursion, Duplicate work and Validation errors.
Salesforce Trigger Interview Questions for Experienced Developers & Consultants
Salesforce Trigger Interview Questions For Experienced Developers focuses on real project problems, automation, bulk data and performance.
Q8. How would you design a trigger for thousands of incoming records?
A. You should make the trigger bulk safe. This means it can handle many records at once. If some work can wait, you can use Queueable Apex. This moves that work out of the main transaction.
Q9. How do you choose between Flow, Trigger, Queueable Apex, and Platform Events?
A. You first look at what the business needs. Then you pick the right tool. Flow can work well for simple record changes. Apex Triggers can handle more complex code. Queueable Apex can run work later. Platform Events can send an event to other parts of a system.
For example, if you only need to update a field, you may use Flow. If you need complex code, you may use Apex. The choice also depends on data size, speed, and how the system should work.
Q10. How do you handle errors without failing unrelated records?
A. You first ask one simple question. Should all records succeed, or can some records fail?
If every record must work, you can use normal DML and let the transaction fail when needed. If some records can fail, you can use Database methods. These methods let me check each record after the DML runs.
For example, you may have 100 records. Three have bad data. If the business allows it, the other 97 records can still be saved.
11. How would you optimize a trigger with too many SOQL queries and DML statements?
You should first look for SOQL queries and DML inside loops. That is often the main problem. For example, you may have 100 Contacts. Each Contact has an Account.
You should not query the Account 100 times.
Instead, you would collect the Account IDs in a Set. Then you would run one SOQL query. You can store the results in a Map and use them later. You would do the same with DML. You would collect the records first. Then you would insert or update them as a group.
Salesforce Trigger Interview Questions Asked in Live Coding Rounds
Q12. Write a trigger to prevent duplicates based on a field.
A. First, you would check if Salesforce can stop the duplicate by itself. You may use a Unique Field or a Duplicate Rule. If you need Apex, you should check for two types of duplicates. you would check old records. you would also check the new records in the same request.
For example, two Leads may come in with the same email. You need to catch both Leads. A check against old records alone may not catch this.
Q13. Write a Bulkified trigger that updates a related parent.
A. First, you should collect the parent IDs in a Set. Then, get the parent records with one SOQL query. Next, make the changes in memory. At the end, use one DML statement to save the parent records. For example, 200 Contacts may belong to 30 Accounts. You should update the 30 Accounts. You should not run 200 DML statements
Q14. How do you create related child records when a parent is inserted?
A. You should use an after-insert trigger when you need the new parent ID. Create the child records in a List. Then, insert all of them at once.
For example, you create a new Account. The trigger can create a default Contact for that Account. Simple. But there is one rule to remember. Do not put DML inside a loop.
Q15. How would you stop a trigger from updating the same records again and again?
A. First, check if the record really changed. Then, run the action only when that change happens.
For example, you may need to create follow-up work when an Opportunity changes to Closed Won. The Opportunity may be updated again later. That update should not create the same work again.
Q16. What is the difference between update and Database.update()?
A. Update uses all-or-none behavior. If one record fails, the whole DML operation can fail. Database.update() can allow partial success when I use allOrNone = false. For example, if you update 100 records and 3 have errors, Database.update(records, false) can save the other 97 records.
Salesforce Trigger Scenario Based Questions: Production Scenarios
These Salesforce Trigger Scenario Based Questions cover real production situations you may face in a Salesforce org.
Q17. How do you prevent trigger recursion?
A. First check if the record or field has really changed. If nothing changes, do not run the code again. This helps stop the trigger from running again and again. You can also use a static variable to control the trigger and stop the same code from running many times in one transaction.
Q18. How do you choose between Flow, Trigger, Queueable Apex, and Platform Events?
A. You should first check what the task needs. Use Flow for simple automation then use an Apex Trigger when you need more complex code. Use Queueable Apex when the work can run later. You can use Platform Events when two systems or processes need to share events.
Q19. How would you design a trigger for thousands of incoming records?
A. You should make the trigger bulkified from the start. Collect record IDs in a Set and run the SOQL query once. You should not run a query for every record. Then, process the records in memory and use bulk DML to save them. If some work can wait, use Queueable Apex for that part.
Q20. How do you handle errors without failing unrelated records?
A. First check if all records must be saved or if some can fail. If all records must work, use normal DML. If some records can fail, you can use Database methods with allOrNone = false. This lets Salesforce save the records that work while the failed records return errors. You can then check those errors and handle them as needed.
Coding & Real-Time Scenarios
Apex Trigger questions can be about real work. An interviewer may give you a problem and ask how you would fix it.
Your code must work with one record and many records. It should also stay within Salesforce limits.
Q1. How would you update related records without SOQL or DML inside a loop?
You can use this simple flow as this keeps the trigger bulk-safe. It also helps avoid Salesforce Governor Limits.
Step | What to do |
1 | Get the record IDs |
2 | Run SOQL once |
3 | Store records in a Map |
4 | Make the changes |
5 | Run DML after the loop |
Q2. How would you make an external callout after a record change?
Don’t make the callout in the trigger itself. Make an asynchronous callout via an asynchronous apex like Queueable Apex.
The basic flow here is – Record Change -> Trigger -> Queueable Apex -> Callout
In this case, the trigger will pass on the necessary information to the queue which will then initiate the callout process. In case the callout fails, you should be able to catch the exception.
Q3. How would you prevent duplicate records in a trigger?
First, see if Salesforce can do the job. You can use:
Unique Field to stop the same value from being used twice.
Duplicate Rule to find possible duplicate records.
If Apex is needed, check two things:
Check records that are already in Salesforce.
Check the new records in the same trigger batch.
This helps stop duplicate records before they are created.
Q4. What would you check if a trigger works for one record but fails during bulk processing?
Start with these checks:
Look for SOQL inside a loop.
Look for DML inside a loop.
Check if the code works only with one record.
Check for repeated work.
Make sure the code can handle many records at once.
When you work with multiple records, use Sets, Lists, and Maps. And then you should test the trigger by using a bulk update and not a single record.
Q5. How would you debug a Flow and Trigger both updating the same record?
Firstly, the Order of Execution should be considered. And then it should be checked which one of them is executed first.
Look for:
Repeated updates,
Recursion,
Doing the same work twice,
Flow and triggers that change the same field.
If both do the same job, try to consolidate it in one place wherever possible. This might help avoid repetitions and errors.
Things Interviewers Commonly Test
When you study Apex Trigger interview questions, start with the basics. But interviewers may ask more. They may ask what happens when many records change at once.
They may ask what happens when an error occurs. They may also ask what happens when Salesforce hits a limit. So, learn how triggers work in real cases. Not just what they mean.
Area | What You Should Know |
Trigger Events | Know when to use before and after triggers. |
Context Variables | Know how Trigger.new and Trigger.old work. |
Bulkification | Know how to make a trigger work with many records at once. |
Governor Limits | Know how to avoid too many SOQL queries, DML actions, and CPU use. |
Recursion | Know why a trigger can run again. Know how to stop extra runs. |
Order of Execution | Know how a trigger works with other Salesforce automation. |
Trigger Structure | Know how to keep your trigger code clean and easy to read. |
Error Handling | Know what happens when a record or transaction fails. |
Asynchronous Apex | Know when some work should run later, outside the main transaction. |
Testing | Know how to test one record and many records. Test both success and error cases. |
Wrapping Up
Before your interview, start with the main Salesforce Trigger Interview Questions. Learn how triggers work in real projects. You should know context variables, Bulkification, Governor Limits, recursion, Trigger Handlers, Order of Execution, and Flow vs. Apex.
If you’re exploring Salesforce as a career option, please check out our Salesforce Online Courses Program from Srijan Institute for more info on learning SAP Skills and your certification options. Ready to test your Salesforce Trigger skills? Start with the questions above. Practice often. Keep your answers clear and simple.
FAQs
Q1. What are the most common Salesforce Trigger Interview Questions topics?
Most common topics are Trigger Events, Context Variables,Bulkification, Governor Limits, Recursion, Trigger Handlers and Order Of Execution.
Q2. What Salesforce Trigger interview question asked in Coding Interviews?
The coding rounds will generally ask for writing Bulkified triggers, preventing duplicates, updating related records, creating child records etc.
Q3. What Salesforce Trigger Questions asked to experienced developers?
Experienced candidates would be asked for Recursion, Automation Conflicts, Performance, Error Handling, Asynchronous Apex & Large Data Volumes.
Q4. How to prepare for Salesforce Trigger Interview Questions?
You can learn trigger concepts, practice Apex coding, and prepare for various real-time scenarios like handling bulk data, governor limits, and automation.
Q5. What are Real-Time Scenarios asked in Salesforce Trigger Interviews?
Common examples include trigger recursion, Mixed DML Errors, UNABLE_TO_LOCK_ROW, Flow vs. Apex issues, Duplicate Records, and more when working with bulk processing.
Turn Knowledge Into Skills
Convert knowledge into job-ready skills with live expert sessions.

Explore Our Top Career Focused Courses
Upskill with industry-relevant training in SAP, Salesforce, Workday & more
Ready to Upgrade Your Skills?
Connect with us today and find the right course for your goals.









