SlideShare a Scribd company logo
1 of 3
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

What's hot

Test-driven development with TYPO3 (T3CON10)
Test-driven development with TYPO3 (T3CON10)Test-driven development with TYPO3 (T3CON10)
Test-driven development with TYPO3 (T3CON10)Oliver Klee
 
Andro sec rl-prototype-finalproject
Andro sec rl-prototype-finalprojectAndro sec rl-prototype-finalproject
Andro sec rl-prototype-finalprojectLiadBercovich
 
Why on Earth would I test if I have to just "Let it crash"?
Why on Earth would I test if I have to just "Let it crash"?Why on Earth would I test if I have to just "Let it crash"?
Why on Earth would I test if I have to just "Let it crash"?Laura M. Castro
 
ExecuteAndWait Interceptor
ExecuteAndWait InterceptorExecuteAndWait Interceptor
ExecuteAndWait InterceptorSeo Trainee
 
Unit testing for the TYPO3 4.x core
Unit testing for the TYPO3 4.x coreUnit testing for the TYPO3 4.x core
Unit testing for the TYPO3 4.x coreOliver Klee
 
RxJava 2 Reactive extensions for the JVM
RxJava 2  Reactive extensions for the JVMRxJava 2  Reactive extensions for the JVM
RxJava 2 Reactive extensions for the JVMNetesh Kumar
 

What's hot (8)

Test-driven development with TYPO3 (T3CON10)
Test-driven development with TYPO3 (T3CON10)Test-driven development with TYPO3 (T3CON10)
Test-driven development with TYPO3 (T3CON10)
 
Andro sec rl-prototype-finalproject
Andro sec rl-prototype-finalprojectAndro sec rl-prototype-finalproject
Andro sec rl-prototype-finalproject
 
Why on Earth would I test if I have to just "Let it crash"?
Why on Earth would I test if I have to just "Let it crash"?Why on Earth would I test if I have to just "Let it crash"?
Why on Earth would I test if I have to just "Let it crash"?
 
Stack - Operations and Applications
Stack - Operations and ApplicationsStack - Operations and Applications
Stack - Operations and Applications
 
ExecuteAndWait Interceptor
ExecuteAndWait InterceptorExecuteAndWait Interceptor
ExecuteAndWait Interceptor
 
Unit testing for the TYPO3 4.x core
Unit testing for the TYPO3 4.x coreUnit testing for the TYPO3 4.x core
Unit testing for the TYPO3 4.x core
 
Specs2 3.4
Specs2 3.4Specs2 3.4
Specs2 3.4
 
RxJava 2 Reactive extensions for the JVM
RxJava 2  Reactive extensions for the JVMRxJava 2  Reactive extensions for the JVM
RxJava 2 Reactive extensions for the JVM
 

Similar to Salesforce interview questions on trigger

11303 dbms chap_02_triggers (2)
11303 dbms chap_02_triggers (2)11303 dbms chap_02_triggers (2)
11303 dbms chap_02_triggers (2)Simarjit Mann
 
Triggers and order of execution1
Triggers and order of execution1Triggers and order of execution1
Triggers and order of execution1Prabhakar Sharma
 
Triggers in plsql
Triggers in plsqlTriggers in plsql
Triggers in plsqlArun Sial
 
Become an Expert in Salesforce Apex Triggers | JanBask Training
 Become an Expert in Salesforce Apex Triggers | JanBask Training Become an Expert in Salesforce Apex Triggers | JanBask Training
Become an Expert in Salesforce Apex Triggers | JanBask TrainingJanBask Training
 
Lab07_Triggers.pptx
Lab07_Triggers.pptxLab07_Triggers.pptx
Lab07_Triggers.pptxKhngNguyn81
 
Ecrire son premier Trigger (et les comprendre)
Ecrire son premier Trigger (et les comprendre)Ecrire son premier Trigger (et les comprendre)
Ecrire son premier Trigger (et les comprendre)Doria Hamelryk
 
Apex Trigger in Salesforce
Apex Trigger in SalesforceApex Trigger in Salesforce
Apex Trigger in SalesforceCloud Analogy
 
Salesforce integration questions
Salesforce integration questionsSalesforce integration questions
Salesforce integration questionsDebabrat Rout
 
Distributed tracing 101
Distributed tracing 101Distributed tracing 101
Distributed tracing 101Itiel Shwartz
 
Monitor(karthika)
Monitor(karthika)Monitor(karthika)
Monitor(karthika)Nagarajan
 

Similar to Salesforce interview questions on trigger (18)

11303 dbms chap_02_triggers (2)
11303 dbms chap_02_triggers (2)11303 dbms chap_02_triggers (2)
11303 dbms chap_02_triggers (2)
 
Triggers and order of execution1
Triggers and order of execution1Triggers and order of execution1
Triggers and order of execution1
 
6. Compile And Run
6. Compile And Run6. Compile And Run
6. Compile And Run
 
Unit 4
Unit 4Unit 4
Unit 4
 
Trigger in mysql
Trigger in mysqlTrigger in mysql
Trigger in mysql
 
Trigger
TriggerTrigger
Trigger
 
Triggers in plsql
Triggers in plsqlTriggers in plsql
Triggers in plsql
 
Become an Expert in Salesforce Apex Triggers | JanBask Training
 Become an Expert in Salesforce Apex Triggers | JanBask Training Become an Expert in Salesforce Apex Triggers | JanBask Training
Become an Expert in Salesforce Apex Triggers | JanBask Training
 
Lab07_Triggers.pptx
Lab07_Triggers.pptxLab07_Triggers.pptx
Lab07_Triggers.pptx
 
Ecrire son premier Trigger (et les comprendre)
Ecrire son premier Trigger (et les comprendre)Ecrire son premier Trigger (et les comprendre)
Ecrire son premier Trigger (et les comprendre)
 
Sql triggers
Sql triggersSql triggers
Sql triggers
 
Distributed Tracing
Distributed TracingDistributed Tracing
Distributed Tracing
 
Apex Trigger in Salesforce
Apex Trigger in SalesforceApex Trigger in Salesforce
Apex Trigger in Salesforce
 
Salesforce integration questions
Salesforce integration questionsSalesforce integration questions
Salesforce integration questions
 
Distributed tracing 101
Distributed tracing 101Distributed tracing 101
Distributed tracing 101
 
Monitor(karthika)
Monitor(karthika)Monitor(karthika)
Monitor(karthika)
 
Trigger
TriggerTrigger
Trigger
 
plsql les10
 plsql les10 plsql les10
plsql les10
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 

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.