SlideShare a Scribd company logo
2
Most read
Salesforce Interview Questions on Trigger
Q. What is trigger?
A. Triggercan invoke apex code,theycome inhandywhenwe wanttoperformsome customtaskjust
before orafterrecord iseithercreatedupdatedordeleted.
Q. What are the various eventon which a trigger can fire?
A. Triggerisa setof statementwhichcanbe executedonthe followingevents:
1. Undelete
2. Update
3. Merge
4. Delete
5. Upsert
6. Insert
Q. Broadly classifythe Trigger?
A. Triggerscan be broadlyclassifiedasbefore orafterTrigger.
 Before triggersare usedtoperforma task before arecord isinsertedorupdatedordeleted.
 Aftertriggersare usedif we want to use the informationsetbySalesforce systemandtomake
changesinthe otherrecords
Q. What are the considerationswhile implementingthe Triggers?
A. Considerthe followingbeforeimplementingthe triggers.
 Upsert triggerfireson4 differentevents:- before(insert,update),after(insert,update)
 Merge triggerare firedonboth eventsondelete
 Fieldhistoryisupdated afterthe triggerhassuccessfullyfinishedprocessingdata.
 Anycalloutshouldbe asynchronoussothattriggerdoesnot have to waitforthe response.
 Triggercannot have a static keywordinitscode.
 If a triggercompletessuccessfullythe changesare committedtothe database andif it failsthe
transactionisrolledback.
Readthe Apex Developerguide formore detailedconsiderations.
Q. Write the syntax of ApexTrigger?
A. TriggerTName OnObjName(namethe events){
……. Apex code here ……..
}
Q. What are context variablesin regards to trigger?
A. Followingare the contextvariable available intriggers.Pleasenote variable’savailabilityvaries
accordingto the type of triggerevents.
1. isExecuting
2. isInsert
3. isUpdate
4. isDelete
5. isBefore
6. isAfter
7. isUndelete
8. new
9. newMap
10. old(update anddelete only)
11. oldMap(update anddelete only)
12. size
Q. How isTrigger.NewDifferentfrom Trigger.newMap?
A. Trigger.New variable returnsthe listof sObjectwhichhasinvokedthe triggerandTrigger.NewMap
returnsthe map of ID’s withthe newlyenteredrecords.NewMapisonlyavailable inafterinsert,before
and afterupdate andafter undelete.
Q. How isTrigger.new differentfromTrigger.old?
A. Trigger.New variable returnsthe listof sObjectwhichhasinvokedthe triggerandTrigger.old returns a
list of the older versions of the records which has invoked the trigger. Trigger.Old is only available in update and
delete events
Q. Can a trigger call a batch class?
A. Yeswe can call a batch classin triggeras we do inthe normal apex code.
Q. Can a trigger make a call to apexcallout method?
A. we can call a calloutmethodinApex Triggerbutthe onlyconditionisthatithasto be an
asynchronouscallout,because the triggerflow cannotwaitonthe response receivedbythe callout
method.
Q. Define Recursive Trigger and how to avoid it?
A. There isa possibilitythatthe resultof triggercanend upcallingthe same triggeragainand can run in
a loop,thisisknownas a recursive trigger.Toavoidthisscenariowe shouldcreate astatic variable and
checkthe value of thisvariable beforewe execute anythinginthe trigger.
Q. What do you mean by bulkifyingtrigger?
A. A triggerthat can handle bothsingle recordandthousandsof record.It iscapable of handlingmass
action.
Q. Is there any limiton number of triggerdefine on a object?
A. We can define asmanytriggeron an objectas we wantbut it isrecommendedtohave one triggerper
objectbecause the orderof executionof differenttriggerisnotguaranteedandanytriggercan fire first.
Q. Can you explainthe order of executioninTriggers?
A. Followingisthe orderof executionof eventswhichsalesforce performbefore aDML Event.
1. Recordis loadedfromdatabase oris initializedincase of upsetstatement.
2. Newrecordfiledvaluesare overwritingthe oldvalues,now dependingonthe originof the
requestthisflowvaries:if the requestisfroma UI page thenthe followingvalidationsare
performedbysalesforce:
a. Anylayoutspecificrulesare checked
b. All the requiredvaluesare checkedatlayoutandfieldlevel
c. All the fieldformatsare validatedalongwiththe maximumlengthof fieldvalues
If the requestoriginatesotherthanUI thenSalesforce onlychecksforValidationof foreignkeys.
3. Nowall the before triggersare executedatthe database.
4. Most of the validationsare performedagaintoverifythatall the requiredfieldsare holding
some valuesandare not null,at thisstepuserdefinedvalidationsare alsoexecutedandthe only
validationwhichare notrepeatedinthisstepare the rulesspecifictolayout.
5. Afterthe successof previousstep,the recordisreviewedforduplicate records,byrunningthe
duplicate rule.If aduplicate isfoundthe flow isstoppedandnofurtheractionsperformed.
6. In thissteprecordis savedtodatabase but itnot committedyet.
7. Nowall the afterTriggersare executed.
8. In thisstepassignmentrulesare executed.
9. Nowif there isany auto response rule ispresentthentheyare executed.
10. Nextinthe queuesare the workflow,theyare executedafterthe autoresponse .
11. If the workflowwasupdatingafield,thenthe fieldsupdatedinthisstepandthe flow afterthis
stepvariesif thiswasthe case.
12. If a fieldwasupdatedthenthe before andafterupdate triggersare firedonce more and
standardvalidationare alsoexecutedagain.Customvalidationescalationrule andduplicate
rulesare not requiredtorunagain.
13. Once the executionhasreachedthisstage,thenprocessare firedif there are anydeclaredon
the object.
14. Nowthe escalationrulesare executed.
15. Entitlementrulesare executedif any.
16. If there are any roll upsummaryfield,thentheyare calculated atthisstepandthe parentobject
go throughthe save process.
17. Nowthe sharingrulesare executed.
18. If we reachthisstage,thenthat meansno errorhas occurred andthe data isreadyto be
committedtothe database and iscommittednow.
19. Nowif there isany postcommitlogiclike email,thenthatisexecuted.

More Related Content

PDF
salesforce triggers interview questions and answers
PPTX
SQL Commands
PPTX
PPT
SQL Tutorial - Basic Commands
PPTX
SQL Data Manipulation language and DQL commands
PDF
Exception handling in plsql
PPTX
5. stored procedure and functions
PPTX
Tree Basic concepts of Tree in Data Structure
salesforce triggers interview questions and answers
SQL Commands
SQL Tutorial - Basic Commands
SQL Data Manipulation language and DQL commands
Exception handling in plsql
5. stored procedure and functions
Tree Basic concepts of Tree in Data Structure

What's hot (14)

PPT
1 - Introduction to PL/SQL
PPTX
Transaction management DBMS
PDF
PDF
PL/SQL TRIGGERS
PPTX
Group By, Having Clause and Order By clause
PPTX
Getting started with postgresql
PPTX
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
PDF
Triggers in SQL | Edureka
PPTX
NLP_KASHK:Morphology
PPT
Data independence
PPTX
Integrity Constraints
PPTX
SQL - Structured query language introduction
PDF
4.3 MySQL + PHP
PPT
Introduction to-sql
1 - Introduction to PL/SQL
Transaction management DBMS
PL/SQL TRIGGERS
Group By, Having Clause and Order By clause
Getting started with postgresql
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Triggers in SQL | Edureka
NLP_KASHK:Morphology
Data independence
Integrity Constraints
SQL - Structured query language introduction
4.3 MySQL + PHP
Introduction to-sql
Ad

Similar to Salesforce interview questions on trigger (20)

PPTX
Triggers and order of execution1
PDF
Ecrire son premier Trigger (et les comprendre)
PPTX
Episode 12 - Basics of Trigger
PPTX
Become an Expert in Salesforce Apex Triggers | JanBask Training
PPTX
Deep Dive into Apex Triggers
PPTX
Episode 20 - Trigger Frameworks in Salesforce
PDF
Decoding Triggers for Admins
DOCX
Interview questions
PDF
Force Academy LA Trigger Framework
PPTX
Apex Trigger in Salesforce
PPT
Apex Trigger Debugging: Solving the Hard Problems
DOCX
Interview questions
PDF
Introduction to Apex Triggers
PPTX
WIT Salesforce Event_T-fest : Lets get more technical
PPTX
Introduction to apex triggers
PPTX
Large Data Volume Salesforce experiences
PDF
Salesforce CRT-450 Platform Developer I Exam Dumps – 2025 Updated Practice Qu...
PPTX
Introduction to apex
PDF
Introduction to Apex Triggers
PDF
Introduction to Apex Triggers
Triggers and order of execution1
Ecrire son premier Trigger (et les comprendre)
Episode 12 - Basics of Trigger
Become an Expert in Salesforce Apex Triggers | JanBask Training
Deep Dive into Apex Triggers
Episode 20 - Trigger Frameworks in Salesforce
Decoding Triggers for Admins
Interview questions
Force Academy LA Trigger Framework
Apex Trigger in Salesforce
Apex Trigger Debugging: Solving the Hard Problems
Interview questions
Introduction to Apex Triggers
WIT Salesforce Event_T-fest : Lets get more technical
Introduction to apex triggers
Large Data Volume Salesforce experiences
Salesforce CRT-450 Platform Developer I Exam Dumps – 2025 Updated Practice Qu...
Introduction to apex
Introduction to Apex Triggers
Introduction to Apex Triggers
Ad

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Approach and Philosophy of On baking technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Machine Learning_overview_presentation.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Cloud computing and distributed systems.
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Weekly Chronicles - August'25-Week II
Chapter 3 Spatial Domain Image Processing.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
MIND Revenue Release Quarter 2 2025 Press Release
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Big Data Technologies - Introduction.pptx
Spectral efficient network and resource selection model in 5G networks
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Approach and Philosophy of On baking technology
The AUB Centre for AI in Media Proposal.docx
Machine Learning_overview_presentation.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Cloud computing and distributed systems.

Salesforce interview questions on trigger

  • 1. Salesforce Interview Questions on Trigger Q. What is trigger? A. Triggercan invoke apex code,theycome inhandywhenwe wanttoperformsome customtaskjust before orafterrecord iseithercreatedupdatedordeleted. Q. What are the various eventon which a trigger can fire? A. Triggerisa setof statementwhichcanbe executedonthe followingevents: 1. Undelete 2. Update 3. Merge 4. Delete 5. Upsert 6. Insert Q. Broadly classifythe Trigger? A. Triggerscan be broadlyclassifiedasbefore orafterTrigger.  Before triggersare usedtoperforma task before arecord isinsertedorupdatedordeleted.  Aftertriggersare usedif we want to use the informationsetbySalesforce systemandtomake changesinthe otherrecords Q. What are the considerationswhile implementingthe Triggers? A. Considerthe followingbeforeimplementingthe triggers.  Upsert triggerfireson4 differentevents:- before(insert,update),after(insert,update)  Merge triggerare firedonboth eventsondelete  Fieldhistoryisupdated afterthe triggerhassuccessfullyfinishedprocessingdata.  Anycalloutshouldbe asynchronoussothattriggerdoesnot have to waitforthe response.  Triggercannot have a static keywordinitscode.  If a triggercompletessuccessfullythe changesare committedtothe database andif it failsthe transactionisrolledback. Readthe Apex Developerguide formore detailedconsiderations. Q. Write the syntax of ApexTrigger? A. TriggerTName OnObjName(namethe events){ ……. Apex code here …….. } Q. What are context variablesin regards to trigger? A. Followingare the contextvariable available intriggers.Pleasenote variable’savailabilityvaries accordingto the type of triggerevents. 1. isExecuting 2. isInsert 3. isUpdate
  • 2. 4. isDelete 5. isBefore 6. isAfter 7. isUndelete 8. new 9. newMap 10. old(update anddelete only) 11. oldMap(update anddelete only) 12. size Q. How isTrigger.NewDifferentfrom Trigger.newMap? A. Trigger.New variable returnsthe listof sObjectwhichhasinvokedthe triggerandTrigger.NewMap returnsthe map of ID’s withthe newlyenteredrecords.NewMapisonlyavailable inafterinsert,before and afterupdate andafter undelete. Q. How isTrigger.new differentfromTrigger.old? A. Trigger.New variable returnsthe listof sObjectwhichhasinvokedthe triggerandTrigger.old returns a list of the older versions of the records which has invoked the trigger. Trigger.Old is only available in update and delete events Q. Can a trigger call a batch class? A. Yeswe can call a batch classin triggeras we do inthe normal apex code. Q. Can a trigger make a call to apexcallout method? A. we can call a calloutmethodinApex Triggerbutthe onlyconditionisthatithasto be an asynchronouscallout,because the triggerflow cannotwaitonthe response receivedbythe callout method. Q. Define Recursive Trigger and how to avoid it? A. There isa possibilitythatthe resultof triggercanend upcallingthe same triggeragainand can run in a loop,thisisknownas a recursive trigger.Toavoidthisscenariowe shouldcreate astatic variable and checkthe value of thisvariable beforewe execute anythinginthe trigger. Q. What do you mean by bulkifyingtrigger? A. A triggerthat can handle bothsingle recordandthousandsof record.It iscapable of handlingmass action. Q. Is there any limiton number of triggerdefine on a object? A. We can define asmanytriggeron an objectas we wantbut it isrecommendedtohave one triggerper objectbecause the orderof executionof differenttriggerisnotguaranteedandanytriggercan fire first.
  • 3. Q. Can you explainthe order of executioninTriggers? A. Followingisthe orderof executionof eventswhichsalesforce performbefore aDML Event. 1. Recordis loadedfromdatabase oris initializedincase of upsetstatement. 2. Newrecordfiledvaluesare overwritingthe oldvalues,now dependingonthe originof the requestthisflowvaries:if the requestisfroma UI page thenthe followingvalidationsare performedbysalesforce: a. Anylayoutspecificrulesare checked b. All the requiredvaluesare checkedatlayoutandfieldlevel c. All the fieldformatsare validatedalongwiththe maximumlengthof fieldvalues If the requestoriginatesotherthanUI thenSalesforce onlychecksforValidationof foreignkeys. 3. Nowall the before triggersare executedatthe database. 4. Most of the validationsare performedagaintoverifythatall the requiredfieldsare holding some valuesandare not null,at thisstepuserdefinedvalidationsare alsoexecutedandthe only validationwhichare notrepeatedinthisstepare the rulesspecifictolayout. 5. Afterthe successof previousstep,the recordisreviewedforduplicate records,byrunningthe duplicate rule.If aduplicate isfoundthe flow isstoppedandnofurtheractionsperformed. 6. In thissteprecordis savedtodatabase but itnot committedyet. 7. Nowall the afterTriggersare executed. 8. In thisstepassignmentrulesare executed. 9. Nowif there isany auto response rule ispresentthentheyare executed. 10. Nextinthe queuesare the workflow,theyare executedafterthe autoresponse . 11. If the workflowwasupdatingafield,thenthe fieldsupdatedinthisstepandthe flow afterthis stepvariesif thiswasthe case. 12. If a fieldwasupdatedthenthe before andafterupdate triggersare firedonce more and standardvalidationare alsoexecutedagain.Customvalidationescalationrule andduplicate rulesare not requiredtorunagain. 13. Once the executionhasreachedthisstage,thenprocessare firedif there are anydeclaredon the object. 14. Nowthe escalationrulesare executed. 15. Entitlementrulesare executedif any. 16. If there are any roll upsummaryfield,thentheyare calculated atthisstepandthe parentobject go throughthe save process. 17. Nowthe sharingrulesare executed. 18. If we reachthisstage,thenthat meansno errorhas occurred andthe data isreadyto be committedtothe database and iscommittednow. 19. Nowif there isany postcommitlogiclike email,thenthatisexecuted.