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
mng0827mng0827 

Trigger to uncheck primary checkbox for multiple contacts

Hi,

The Primary checbox field on our Contacts is enabled to "Checked" by default. If we want to add more contacts under the same account, then this should no longer be checked if it already has a primary contact. How can this be done using a trigger?

Thanks
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
You can write a trigger on contact object to check if it has primary contact.

1. Query all contacts related to account of current contact.
2. Check if any of these is primary one

You might have to consider few senarios like what happens when primary contact is deleted etc.

Thanks,
N.J
mng0827mng0827
Good point on considering deleted primary contacts. But this is less likely to happen since users do not have that permission. I'll try out what you suggested. Thanks for your help!