Apex Trigger Practice (2) – update the Contact based on Contact Role

Question Related Components:

  • Contact Object
    • Primary: a custom checkbox field 
  • Opportunity
    • A Custom field – “Primary Contact”- lookup to contact
  • OpportunityContactRole: is a standard junction object under Contact and Opportunity. And having Field “Role” having a picklist value “Primary”. If not there in your org then add it.

Requirement:

  • If there is any OpportunityContactRole with role=”Primary” then copy this Contact on Opportunity as Primary Contact.
  • If a contact is associated with any opportunity as “Primary Contact” then “Primary” checkbox should be checked.

Implementation Verification:

Upload your code in Github and provide the link of public repo in comment below, it will be reviewed based on availability and feedback will be shared.

P.S: Be honest, watch the clock to check your efficiency. Happy coding.

1 thought on “Apex Trigger Practice (2) – update the Contact based on Contact Role”

Comments are closed.