1

Running Drupal 7.43 and civicrm 4.7.12.

We sell memberships to individuals and organisations.

The creation of an Individual works fine. The contact is created and the Drupal account created.

When signing up as an organisation with a name/address/email/create drupal profile, I get the error:

DB Error: already exists.

And the fatal error in Drupal logs:

$Fatal Error Details = Array ( [callback] => Array ( [0] =>  
CRM_Core_Error [1] => handle ) [code] => -5 [message] => DB Error:   
already exists [mode] => 16 [debug_info] => 
   INSERT INTO civicrm_uf_match (domain_id, uf_id , uf_name , contact_id) 
   VALUES ( 1 , 1229 , 'user@ns9.com' , 2603 ) 
[nativecode=1062 ** Duplicate entry 'user@ns9.com-1' for key 
'UI_uf_name_domain_id'] [type] => DB_Error [user_info] => INSERT INTO   
civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 , 
1229 , 'user@ns9.com' , 2603 ) [nativecode=1062 ** Duplicate entry 
'user@ns9.com-1' for key 'UI_uf_name_domain_id'] [to_string] => 
db_error: 
message="DB Error: already exists" code=-5 mode=callback      
callback=CRM_Core_Error::handle prefix="" info="INSERT INTO 
civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 , 
1229 , 'user@ns9.com' , 2603 ) [nativecode=1062 ** Duplicate entry 
'user@ns9.com-1' for key 'UI_uf_name_domain_id']"] )

Weird thing is that it seems to work fine.

  • Organisation is created and given membership.
  • Individual is created with relationship to organisation
  • Drupal account is created for Individual

But they are just given the error and not logged in.

I can get them to manually create an account after creating membership and link it to their civicrm contact, but it seems like an unneeded extra step for users.

Maybe I need to use civicrm_entity and trigger a rule? Thanks

2

In the database table that links CMS users to CiviCRM contacts, we store a few things:

  • The CMS user ID (in Drupal's case, the "uid")
  • The CiviCRM contact ID
  • The email address that both records have in common.

Crucially - all three must be unique! For instance, you can't have a single CiviCRM contact linked to two Drupal user accounts.

The error you're seeing says, "Hey, Civi tried to create a link between a Drupal user and a Civi contact, but we found that another record in this table already uses that same email address."

Based on that - I'd guess that something about your setup is causing Drupal to try to create two user accounts at once - one connected to the individual and one for the organization.

Without knowing more about your setup, I can't tell you the exact steps to fix it, but hopefully this will make the solution clear to you.

One last thing: In CiviCRM, there's a philosophy of not creating "organization" accounts. "Organizations" can't log into websites; individuals can. So if what you're trying to do (it's not 100% clear from the question) is create two logins, consider instead using the relationship permissions to allow the individual to edit the organization instead.

  • Hi, thanks for the quick and thoughtful response. I'm not trying to create an drupal user for the organisation. Just for the person filling out the contribution page on behalf of the organisation. Is this possible. I've tried attaching a New Individual and create drupal account profile but getting issues above. – joewickert Nov 2 '16 at 3:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.