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
Ty WhitfieldTy Whitfield 

Validator that checks if multiple contacts have the same entry on a field

I have a picklist field on the Contact record but I only want one person from each account to have one of the picklist values selected in this case "Admin User".  The other picklist values may have mulitple contacts with the same item selected, just the Admin user needs to be unique.  

I'm assuming that I would have to write a trigger on Contact edit but how do I display the error to the user about to update the record?
Best Answer chosen by Ty Whitfield
Raj VakatiRaj Vakati
You need to write the trigger to do this .. but you can show error by using addError method on from the trigger

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_exceptions.htm
 
<Record >.addError('Overlap Session');