form validation for unique fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamie
    Senior Member
    • Aug 2025
    • 101

    #1

    form validation for unique fields

    Steps to Reproduce:
    1. Attempt to create or update any record in EspoCRM with a value that violates a unique constraint (e.g., duplicate number, email, or other unique field).
    2. Submit the form.

    Expected Behavior:
    • The form should display a validation error indicating which field violates the uniqueness constraint.

    Actual Behavior:
    • Submission fails with a 500 error instead of a user-friendly validation message.
    • Example error in log:
    [2025-10-01 13:47:39] CRITICAL: (23000) SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Q-02904-Ad' for key 'UNIQ_C_SALES_QUOTE_NUMBER' :: POST /Quote :: /var/www/html/application/Espo/ORM/Executor/DefaultSqlExecutor.php(77)
    Environment:
    • EspoCRM version: 9.1.8
    • PHP version: 8.3
    • Database: maria db
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9440

    #2
    It's not a bug. We don't have such a feature currently. It needs to be handled manaully (in a hook or a wrapper).
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • jamie
      Senior Member
      • Aug 2025
      • 101

      #3
      Originally posted by yuri
      It's not a bug. We don't have such a feature currently. It needs to be handled manually (in a hook or a wrapper).
      might this be something you'll be adding in the future?

      Comment

      • yuri
        EspoCRM product developer
        • Mar 2014
        • 9440

        #4
        It was considered before.

        For now, I suggest to add to call an additional check in before create/save record hook and throw a Conflict exception with a message body. We've done it multiple time.
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment


        • jamie
          jamie commented
          Editing a comment
          But no plans for the future? I'd hate to implement something that will be included in the near future

          Anywhere I can look for examples on how to implement?
      Working...