Skip to content
CodersBugs Logo 2025
  • Home
  • Salesforce
    • Interview Q & A
    • Company Wise Interview Questions
    • Lightning Web Components
    • Triggers
    • Apex
    • Flows
  • Blogs
Menu Close
  • Home
  • Salesforce
    • Interview Q & A
    • Company Wise Interview Questions
    • Lightning Web Components
    • Triggers
    • Apex
    • Flows
  • Blogs

Apex Triggers Scenarios With Code

Scenario 1: On Lead we have custom  lookup field named Company Owner(User), also Company(Account) field. On Account we have custom field called CEO(User), While creating Lead If Linked Company has SEO then populate that in Company Owner.

Scenario 2: When Account Email get updated all related Contact Email Should get updated.

Scenario 3: When Opportunity get updated. Create new Task on Primary Contact of that Opportunity.

Scenario 4: Write a trigger logic such as if Account Rating change from Hot to any then delete all upcoming Task associated with that Account.

Scenario 5: Write a trigger logic to prevent Account from Deleting if it has Opportunities associated to it.

Scenario 6: When Opportunity get Closed Send Email to Opportunity Owner

Scenario 7: Write trigger syntax to find all Account related Contacts when an Account is Updated.

Scenario 8: We have two custom object Meeting, Guest on Meeting we have field Status (Scheduled, In-Progress, Completed). On Guest we have Meeting lookup. Write logic such as If Meeting Status is ‘Completed’ then we should not able to link Guest to that Meeting.

Scenario 9: Write Trigger on Contact to prevent inserting or updating duplicate Contacts. Use Email field to compare with existing Contacts record.

Scenario 10: While inserting Contact check if linked Account is already associated to other Contact. Throw Error is yes.

  • About Us
  • Contact
  • Youtube
  • Ask to Expert
  • Pattern Programs
  • Blogs
  • Privacy Policy

CodersBugs © 2024 All rights reserved