Announcement

Collapse
No announcement yet.

Unique phone number

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unique phone number

    Hello,
    Very nice CRM but we are having an issue while creating contacts or leads becase callers are able to add same phone number twice. Is there any way to make phone number unique? For example with message like "Phone number already exists".
    Thank you
    Last edited by Espire; 06-10-2023, 12:01 PM.

  • #2
    You could try to add the key “unique”: true to the field in the entityDefs related file.

    I don’t know if it will work for the phone number field

    Comment


    • #3
      It seems that Unique is not available for the Phone number. 😐
      Is it possible to use the following to accomplish it https://docs.espocrm.com/administrat...icate-checking ?
      Last edited by Espire; 06-11-2023, 09:45 PM.

      Comment


      • #4
        Originally posted by Espire View Post
        Hello,
        Very nice CRM but we are having an issue while creating contacts or leads becase callers are able to add same phone number twice. Is there any way to make phone number unique? For example with message like "Phone number already exists".
        Thank you
        Unique will not work, phone is saved in database in two different tables (phone_number) and (entity_phone_number). i think one way to do it, is to use formula so when the user create a new phone which already exist the formula should just delete that phone number, e.g a contact entity when a user create a new phone number for a contact and that phone number already exist then just delete the last one. see code below :

        PHP Code:
        ifThen(phoneNumber && record\exists('Contact''phoneNumber='$phoneNumber),
        $entityPhoneNumberId record\findOne('EntityPhoneNumber'nullnull'entityId='id);
        record\update('EntityPhoneNumber'$entityPhoneNumberId'deleted'true);
        );
        ​ 
        Otherwise you could use Save Error Handlers which come handy will display a message to the user preventing them from adding an existing phone. i have written a post about how to implement, you can just adjust the code to your entity and it should work.

        http://​​​​​​​https://forum.espocrm.com/forum/developer-help/developer-tutorials/92483-save-error-handlers-throw-backend-exception-handle-in-frontend-when-saving-a-record#post92483
        Rabii
        Web Dev

        Comment

        Working...
        X