Real-time scenarios on Triggers

Let us look at some Real-time scenarios on Triggers

This is one of the most frequently asked questions related to Salesforce.

I too googled it and relised that there is not enough content on it, so deciede to create it.

I had put together a list of scenarios that we can use for practise, let me walk you through it.


  • When a field is updated, in the same record try to update another field.
  • When a field is updated, in the parent record try to update a field.
  • Execute Trigger and create a Task record only when a specific field has changed (status in leads).
  • When the record is updated make sure all the child records Owner Id is updated.
  • Prevent a record from being edited if the record is created 365 days back.


  • Replicate rollup summary functionality on lookup objects
  • Check the count of tasks, if it’s less than 10 (<10) then make the owner as user one else make the owner as user
  • When inserting a lead if it already exits then automatically create a new Contact, Opportunity and Account and delete the existing record (you can use email id for de-dupe).
  • Lead is created as Working - Contacted or with status updated to Working - Contacted from a different value make a callout to any dummy endpoint.


  • When the owner of Account is changed, change all the owners of accounts in hierarchy and the owner of contacts, cases and Oppty’s and vice-verse bi-directional.
  • Whenever account phone is modified then update old phone numbers field with CSV values (if and only if the new phone no is not part of any of the associated contacts).

When a new account is created with annual revenue more than 50,000 whose the owner? (below 4 points are related to this question)

  • Take the accounts, get their opportunities and their amount if the amount is greater than 100,000, then owner is Teja.
  • Take the accounts, get theirs opportunities, if the Opportunity Product’s   are more than 10 for the user whose inserting the record.
  • Take the accounts, get their opportunities, if there exists at least 10 closed won Oppty’s and 20 Opportunity Product’s which are created 2 years back, then the owner is Krishna.
  • When an Account is updated, if there exists at least two opportunities for each stage then update the field on Contacts that they are High Priority contacts (or send less no of email to them).

  • Mute triggers for specific objects when data loader is used, get this info from  custom settings.
  • When duplicates(lead) are found re-parent all the child records to the oldest record (remove all the tasks from other records) and delete the duplicate records apart from the oldest record.

Hope this is helpful!