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 Import (Moderator: Yashodha Chaku) »
  • importing external id troubles
Pages: [1]

Author Topic: importing external id troubles  (Read 1500 times)

sacramentorob

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4.2.1
  • CMS version: Joomla 2.5.6
  • MySQL version: 5.1.63 ubuntu
  • PHP version: 5.3.2 ubuntu
importing external id troubles
July 23, 2012, 09:25:34 am
hi Folks,

I am trying to import an update to about 400 of my contacts.  My import list has First Name, Last Name and an external identification field. 

When I import the list, the First Name and Last Name all match up but the External Identification field is not populated. 

I have tried this with three import option.  I've tried with External ID as an integer and a text string.  These are the results

Skip:  nothing is imported because all the names match
Update:  External ID not populated
Fill:  External ID not populated

Does anyone know a way to fix this? 

Thanks,
/Rob

System information
PHP Built On    Linux Server 2.6.32-37-generic-pae #81-Ubuntu SMP Fri Dec 2 22:24:22 UTC 2011 i686
Database Version    5.1.63-0ubuntu0.10.04.1
Database Collation    utf8_general_ci
PHP Version    5.3.2-1ubuntu4.17
Web Server    Apache/2.2.14 (Ubuntu)
WebServer to PHP Interface    apache2handler
Joomla! Version    Joomla! 2.5.6 Stable [ Ember ] 19-June-2012 14:00 GMT
Joomla! Platform Version    Joomla Platform 11.4.0 Stable [ Brian Kernighan ] 03-Jan-2012 00:00 GMT

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: importing external id troubles
July 23, 2012, 09:34:12 am
I've also occasionally had issues with imports on the "match fields" (those fields which are marked in red on the import mapping screen) when I wasn't actually using them as a match field.

I hope someone has a more "correct" answer for you, but in this instance, if I understand your situation correctly - you only need to import external identifiers to existing records that have matching first/last names -  I'd probably import external identifiers directly into MySQL in civicrm_contact.  Assuming you loaded your CSV file into a table temp_id, something like this should work:
UPDATE `civicrm_contact` a, `temp_id` b SET a.external_identifier = b.external_identifier WHERE a.first_name = b.first_name AND a.last_name = b.last_name
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

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: importing external id troubles
July 23, 2012, 09:49:14 am

seems wierd :( can you try this on our demo server and see if you get the same results

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

sacramentorob

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4.2.1
  • CMS version: Joomla 2.5.6
  • MySQL version: 5.1.63 ubuntu
  • PHP version: 5.3.2 ubuntu
Re: importing external id troubles
July 23, 2012, 05:58:34 pm
Thanks for the quick reply.

I tried the drupal demo site and I got the same behavior.  I created two contacts, Johnn Doee and Johhn Dooe.  I didn't touch the External ID field.  I created a csv file with those two names and an external ID.  I executed the imports with the Update and Fill options.

In both cases, the special tag I created was set true but the external ID remained blank.

I'm still learning m way around the code so I can't help much with this.  Sorry about that.

I'd appreciate any help you can offer with this.

On the mysql approach.  I'll give  that a try!  Thanks for the idea and the snippet.  I have to admit, I'm a little worried about taking the training wheels off my scooter, but we all have to grow up sometime, eh?

Thanks again,
/Rob

ps i attached the csv file if you want to have a go at it yourself.
« Last Edit: July 23, 2012, 06:06:12 pm by sacramentorob »

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: importing external id troubles
July 24, 2012, 06:55:00 am

i tried with the skip option and it worked fine.

I suspect for update/fill it assumes that an external ID is already present and uses that for matching

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

sacramentorob

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4.2.1
  • CMS version: Joomla 2.5.6
  • MySQL version: 5.1.63 ubuntu
  • PHP version: 5.3.2 ubuntu
Re: importing external id troubles
July 24, 2012, 12:58:41 pm
again, thank you so much for helping me with this.

I'm still getting my original results.

I tried the import on my system with the "Skip" selection.  I had the duplicate checking based on FirstName and LastName only.  If both of those matched, the "Skip" flag was set so the record wasn't imported.  No changes occurred.  In the case where they matched but the threshold was set higher than the match total, the "Skip" flag wasn't set and the full contact was imported.  I ended up then with two of each Johhn and Johnn.

When I tried other cases, "Update" and "Fill," when there was a match only the new Tag was added to the contact.  No "External Id" changes were recorded.

Actually, the only way I could get an "External ID" to import is when there was no match so a new contact was just created.

I went back and tested this on both the Joomla and Drupal demo sites.  I can't find a way to have the match occur and to have the database "ExternalID" value changed.

Are you sure you didn't just import new contacts rather than change the old ones?  Someone might have erased the originals.

I've attached a new test file.  If you import it, then edit the "External ID" numbers and re-import it with matching on, I really hope the "External ID" values change but I suspect they won't.

Thanks again for helping out on this.  I really appreciate it!

/Rob

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: importing external id troubles
July 24, 2012, 01:58:58 pm

yes, i just imported new contacts. I suspect the import code disregards external ID for existing contacts. If i had to guess, this is primarily because we also allow folks to match contacts based on external ID

There will need to be a code change to accomplish what you need. Would be good if you can dive into the code and submit a patch. The import code is a bit old and complex (IMO)

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

sacramentorob

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4.2.1
  • CMS version: Joomla 2.5.6
  • MySQL version: 5.1.63 ubuntu
  • PHP version: 5.3.2 ubuntu
Re: importing external id troubles
July 24, 2012, 04:12:43 pm
Thanks again.  I'll paw around in there some and see if I can figure something out.


sacramentorob

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4.2.1
  • CMS version: Joomla 2.5.6
  • MySQL version: 5.1.63 ubuntu
  • PHP version: 5.3.2 ubuntu
Re: importing external id troubles
July 25, 2012, 11:55:14 am
just reporting in,

i got the data to go where i wanted by importing it to legal_identifier and then using myphpadmin to copy the data column to external_identifier.   

It was a very simple command:
update IGNORE civicrm_contact set external_identifier=legal_identifier where legal_identifier is not null;

This worked because i didn't have any data in legal_identifier to start with.  I would have to have created a new column otherwise.  The ignore was because two of the contacts had the same legal_identifier stemming from a deletion that hadn't been purged yet.  I had to correct these two manually.

Thanks for the help.  I learn a lot,

/Rob
« Last Edit: July 25, 2012, 12:03:43 pm by sacramentorob »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • importing external id troubles

This forum was archived on 2017-11-26.