function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kian SalehizadehKian Salehizadeh 

Check a checkbox if a Contact has an associated Opportunity or Meeting

This is my first time trying to code a trigger in Salesforce. I have a checkbox labeled "Priority Contact," and I'd like the checkbox to be checked for all contacts that have at least one Opportunity or Meeting event linked to them. Could you please advise on how I should go about doing this? I'm also not 100% sure where to enter the code to activate the trigger. Thank you.
Samruddhi GokhaleSamruddhi Gokhale
Write a trigger on Opportunity so that whenever an opportuniy is added, you will set the checkbox on associated contact to true. Also notice that your trigger should uncheck the checkbox when an opportunity is deleted (only if that is the only opportunity associated with that contact)
Kian SalehizadehKian Salehizadeh
Do you have any sample code you can provide to help me get started with this?  I have no background in the coding side of things.