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
Sam Hummel 4Sam Hummel 4 

Communities causes problems when enabling DupeBlocker for User object

I want to enable DupeBlocker for the User object precisely because I think it would be really helpful for detecting and merging duplicate user records created by the same individual in my Customer Community.  However, when I tried enabling DupeBlocker for the User object in my Production org, I got the below very nasty error message that I can't figure out how to parse.  Clearly, it has to do with the unit tests related to Communities, but I don't even know where to get started in solving the problem.  I'm guessing that 99% of the long error message is being generated as a result of one or two errors that probably make up 1% of the error message.  Can anybody help me find that nugget and figure out what I need to change with my unit tests?  

Thank you in advance for any help you can provide!


Enable Object Error

Unexpected error encountered:

<details xmlns="http://soap.sforce.com/2006/04/metadata"><componentSuccesses><changed>true</changed><created>true</created><deleted>false</deleted><fileName>classes/DB_Custom_User.cls</fileName><fullName>DB_Custom_User</fullName><id>01pF0000003jJ8EIAU</id><success>true</success></componentSuccesses><componentSuccesses><changed>true</changed><created>true</created><deleted>false</deleted><fileName>triggers/DB_Custom_User.trigger</fileName><fullName>DB_Custom_User</fullName><id>01qF0000000rEwjIAE</id><success>true</success></componentSuccesses><componentSuccesses><changed>true</changed><created>false</created><deleted>false</deleted><fileName>package.xml</fileName><fullName>package.xml</fullName><success>true</success></componentSuccesses><runTestResult><codeCoverage><id>01qF0000000rCVzIAM</id><locationsNotCovered><column>0</column><line>9</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>10</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>11</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>14</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>15</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>17</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>18</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>23</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>24</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>25</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>26</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><name>chatter_answers_question_escalation_to_case_trigger</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>17</numLocations><numLocationsNotCovered>11</numLocationsNotCovered><type>Trigger</type></codeCoverage><codeCoverage><id>01pF0000003EIRAIA4</id><locationsNotCovered><column>0</column><line>15</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><name>ForgotPasswordController</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>9</numLocations><numLocationsNotCovered>1</numLocationsNotCovered><type>Class</type></codeCoverage><codeCoverage><id>01pF0000003EOphIAG</id><locationsNotCovered><column>0</column><line>7</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>8</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><name>CommunitiesLandingController</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>3</numLocations><numLocationsNotCovered>2</numLocationsNotCovered><type>Class</type></codeCoverage><codeCoverage><id>01qF0000000rEwjIAE</id><locationsNotCovered><column>0</column><line>7</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>14</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>16</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>20</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>21</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><name>DB_Custom_User</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>9</numLocations><numLocationsNotCovered>5</numLocationsNotCovered><type>Trigger</type></codeCoverage><codeCoverage><id>01pF0000003EIR8IAO</id><name>ChangePasswordController</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>6</numLocations><numLocationsNotCovered>0</numLocationsNotCovered><type>Class</type></codeCoverage><codeCoverage><id>01pF0000003jIJpIAM</id><name>Q_A_redirect</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>0</numLocations><numLocationsNotCovered>0</numLocationsNotCovered><type>Class</type></codeCoverage><codeCoverage><id>01pF0000003EOplIAG</id><name>CommunitiesSelfRegConfirmController</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>1</numLocations><numLocationsNotCovered>0</numLocationsNotCovered><type>Class</type></codeCoverage><codeCoverage><id>01qF0000000rEweIAE</id><locationsNotCovered><column>0</column><line>14</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>16</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><name>DB_Custom_Case</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>9</numLocations><numLocationsNotCovered>2</numLocationsNotCovered><type>Trigger</type></codeCoverage><codeCoverage><id>01pF0000003EIR4IAO</id><name>SiteLoginController</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>6</numLocations><numLocationsNotCovered>0</numLocationsNotCovered><type>Class</type></codeCoverage><codeCoverage><id>01pF0000003EOpfIAG</id><name>CommunitiesLoginController</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>5</numLocations><numLocationsNotCovered>0</numLocationsNotCovered><type>Class</type></codeCoverage><codeCoverage><id>01pF0000003EIR6IAO</id><locationsNotCovered><column>0</column><line>39</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>40</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>43</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>44</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>45</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><name>SiteRegisterController</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>28</numLocations><numLocationsNotCovered>5</numLocationsNotCovered><type>Class</type></codeCoverage><codeCoverage><id>01pF0000003EIRCIA4</id><locationsNotCovered><column>0</column><line>21</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>35</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>41</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>44</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>45</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><name>MyProfilePageController</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>40</numLocations><numLocationsNotCovered>5</numLocationsNotCovered><type>Class</type></codeCoverage><codeCoverage><id>01pF0000003EOpjIAG</id><locationsNotCovered><column>0</column><line>45</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>46</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>49</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>50</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><locationsNotCovered><column>0</column><line>51</line><numExecutions>0</numExecutions><time>-1.0</time></locationsNotCovered><name>CommunitiesSelfRegController</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>33</numLocations><numLocationsNotCovered>5</numLocationsNotCovered><type>Class</type></codeCoverage><codeCoverage><id>01pF0000003FKUHIA4</id><name>ChatterAnswersRegistration</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><numLocations>4</numLocations><numLocationsNotCovered>0</numLocationsNotCovered><type>Class</type></codeCoverage><failures><id>01pF0000003jJ8EIAU</id><message>System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_USERNAME, Duplicate Username.&lt;br&gt;Another user has already selected this username.&lt;br&gt;Please select another.: [Username]</message><methodName>testTrigger</methodName><name>DB_Custom_User</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><packageName>DB_Custom_User</packageName><stackTrace>Class.DB_Custom_User.testTrigger: line 9, column 1</stackTrace><time>466.0</time><type>Class</type></failures><numFailures>1</numFailures><numTestsRun>15</numTestsRun><successes><id>01pF0000003EIR9IAO</id><methodName>testChangePasswordController</methodName><name>ChangePasswordControllerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>157.0</time></successes><successes><id>01pF0000003FKUJIA4</id><methodName>validateAccountCreation</methodName><name>ChatterAnswersCreateAccountTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>364.0</time></successes><successes><id>01pF0000003FKUIIA4</id><methodName>validateQuestionEscalation</methodName><name>ChatterAnswersEscalationTriggerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>443.0</time></successes><successes><id>01pF0000003EOpiIAG</id><methodName>testCommunitiesLandingController</methodName><name>CommunitiesLandingControllerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>36.0</time></successes><successes><id>01pF0000003EOpgIAG</id><methodName>testCommunitiesLoginController</methodName><name>CommunitiesLoginControllerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>32.0</time></successes><successes><id>01pF0000003j8o8IAA</id><methodName>myUnitTest</methodName><name>CommunitiesRegHandlerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>38.0</time></successes><successes><id>01pF0000003EOpmIAG</id><methodName>testCommunitiesSelfRegConfirmController</methodName><name>CommunitiesSelfRegConfirmControllerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>36.0</time></successes><successes><id>01pF0000003EOpkIAG</id><methodName>testCommunitiesSelfRegController</methodName><name>CommunitiesSelfRegControllerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>36.0</time></successes><successes><id>01pF0000003jJ89IAE</id><methodName>testTrigger</methodName><name>DB_Custom_Case</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>692.0</time></successes><successes><id>01pF0000003EIRBIA4</id><methodName>testForgotPasswordController</methodName><name>ForgotPasswordControllerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>38.0</time></successes><successes><id>01pF0000003EIRDIA4</id><methodName>testSave</methodName><name>MyProfilePageControllerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>708.0</time></successes><successes><id>01pF0000003EIRDIA4</id><methodName>testSetContactFields</methodName><name>MyProfilePageControllerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>149.0</time></successes><successes><id>01pF0000003EIR5IAO</id><methodName>testSiteLoginController</methodName><name>SiteLoginControllerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>38.0</time></successes><successes><id>01pF0000003EIR7IAO</id><methodName>testRegistration</methodName><name>SiteRegisterControllerTest</name><namespace xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><time>31.0</time></successes><totalTime>3338.0</totalTime></runTestResult></details>
Best Answer chosen by Sam Hummel 4
ShashForceShashForce
This is the actual error:

System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_USERNAME, Duplicate Username.&lt;br&gt;Another user has already selected this username.&lt;br&gt;Please select another.: [Username]