UrbanPro
true

Learn Salesforce Administrator from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

When To Use Before Triggers And When To Use After Triggers?

Kumar
05/08/2017 0 0

1. Before Triggers:

To perform the validations we should use before triggers.

If you are updating any field on the same object on which you are writing the trigger and no need to explicitly include the DML statemetns (already due to DML operation only trigger fire and it is still in progress at this point of time.)

2. After Triggers:

If you are dealing with relationship records and if you need record id in these situations we should use after trigger (in before insert record doesn't contain the record id).

3. For the same event if there are multiple triggers on the object, how to control the order of execution?

We cannot control the order of execution in this situation. It is recommended to have only one trigger per one object.

Note: We can keep the logic of the apex trigger in an apex class and can invoke from that class.

4. What are the recursive triggers and how to avoid?

If we perform update operation on the record in after update event logic recursive triggers will arise.

Using static boolean variable in an apex class (we should not keep static boolean variable inside of the trigger) we can avoid recursive triggers.

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

How to Learn salesforce easily?
Steps: 1.Know the course content. 2. Collect all materials. 3. Separate all materials into A.Admin B.Development C.Project. 4. Get the best trainer and follow him/her. 5. Update your skills with the help of all available resources.

What is SFDC Architecture.
SFDC is built based on the MVC Pattern.Model - Which is handle the Database Objects View - Which will take care of the UI pages. Controllers- The business logic Implementation will be done here.

Trigger Sceniors - session 5
//Trigger Check Duplicate before insert, before update Set leadid = new Set(); Map<String,Lead> phonemap = new Map<String,Lead>(); Map<String,Lead> emailmap = new Map<String,Lead>();...
S

Assigning One permission to multiple users automatically without any manual work.
Hi Friends,I recently came across below new things I did in my project. Hope it helps you too.Description :How to Assign one permission set to multiple Users ? For example: If I want to assign ONE permission...

Difference Between Workflows, Process Builder, Triggers.
Difference Between Workflows, Process Builder, Triggers. Workflows: Which is Automated business proces with help of New Task, Email Alert, Field Update, Outbound Messages. Process Builder: Which is...
X

Looking for Salesforce Administrator Classes?

The best tutors for Salesforce Administrator Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Salesforce Administrator with the Best Tutors

The best Tutors for Salesforce Administrator Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more