CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • problems with duplicate keys when importing contacts into new groups
Pages: [1]

Author Topic: problems with duplicate keys when importing contacts into new groups  (Read 483 times)

daveatkins

  • I post occasionally
  • **
  • Posts: 68
  • Karma: 2
  • CiviCRM version: 4.1.6
  • CMS version: Drupal 6.28
  • MySQL version: 5.1.41
  • PHP version: 5.2.10
problems with duplicate keys when importing contacts into new groups
June 27, 2012, 09:44:07 am
I am getting errors when I create new groups with similar names when importing contacts. For example, here is a list of the groups I want to create:

Residential Gas Water Heating> Water Heater Retailers
Residential Gas Water Heating> Water Heater Trade Assoc
Residential Gas Water Heating> Water Heater Mfr
Residential Gas Water Heating> Water Heater Distributors

The first one goes ok, but then I get database errors like this:

    [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_group (name , title , description , is_active , group_type ) VALUES ('Residential_Gas_Water_Heating_g' , 'Residential Gas Water Heating> Water Heater Mfr' , 'from ACT' ,  1 ,  NULL )  [nativecode=1062 ** Duplicate entry 'Residential_Gas_Water_Heating_g' for key 3]"]

That looks like a database design issue: the key length is too short. I am on version CiviCRM v3.4.6 - perhaps this has just been fixed in 4.x?

My naming convention above--which results in long group names--is to get around Civi's lack of support for a display hierarchy in groups. Maybe that is enhanced also and it is time to upgrade? Until then what can I do? (I do not want, at this point, to rename the groups to be shorter because this whole approach is already in place for hundreds of groups--some of which are OG-synced from Drupal)

daveatkins

  • I post occasionally
  • **
  • Posts: 68
  • Karma: 2
  • CiviCRM version: 4.1.6
  • CMS version: Drupal 6.28
  • MySQL version: 5.1.41
  • PHP version: 5.2.10
Re: problems with duplicate keys when importing contacts into new groups
June 27, 2012, 10:37:28 am
one workaround is to name the group with a shorter unique name initially, then rename it to the desired longer name. In the database, the initial name is the key

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: problems with duplicate keys when importing contacts into new groups
June 27, 2012, 11:56:29 am

Just checked the code base and seems like this is still an issue with 4.x

Would be good if you can investigate and submit a patch that fixes this for 4.3. I suspect its a fairly easy patch (if name is too long, then md5 a section of the name and truncate name to a smaller length)

Ping us on IRC if you need help getting started

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • problems with duplicate keys when importing contacts into new groups

This forum was archived on 2017-11-26.