Hi, is it possible to set the email address field for Users and Contacts as UNIQUE in EspoCRM to prevent duplicates? If so, how can this be configured?
Set emails to UNIQUE
Collapse
X
-
Hi drychly,
You can either configure the fields for duplicate check in the Contact and User entity settings (Administration > Entity Manager > {entity_name} > Edit) or use the API Before-Save Script: https://docs.espocrm.com/administrat...licateconflict. -
drychly,
In this case, you can use the API Before-Save Script.
In Administration > Entity Manager > Contact > Formula > API Before Save Script:
Code:$id = record\findOne('Contact', null, null, 'emailAddress=', emailAddress); if ($id) { recordService\throwBadRequest('There is already a contact with this email address in the system.') }
Code:$id = record\findOne('User', null, null, 'emailAddress=', emailAddress); if ($id) { recordService\throwBadRequest('There is already a user with this email address in the system.') }
Comment
Comment