Unique user Names

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rmorgan
    Member
    • Feb 2019
    • 51

    #1

    Unique user Names

    It seems that ESPOCRM allows more than one user to have the same name, e.g. I could have two people called 'Fred Bloggs'. This will cause potential issues when running reports. Is there a way to enfore unique names? I believe it already does this with usernames.
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1701

    #2
    I did not test it, but you could try to prevent that with API Before Save Script formula, like so:

    Code:
    // Assuming you want to prevent duplicate username in user
    if (recordExists('User', 'userName = ' + this.userName)) {
    throw new Error('this Username already exists.');
    }

    Comment

    • yuri
      Member
      • Mar 2014
      • 9132

      #3
      Correction:

      Code:
      if (record\exists('User', 'userName=', userName)) {
          recordService\throwConflict("User already exists.");
      }
      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

      Working...