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 Drupal Modules (Moderator: Donald Lobo) »
  • Drupal User Import - Duplicate Contact Created in CiviCRM
Pages: [1]

Author Topic: Drupal User Import - Duplicate Contact Created in CiviCRM  (Read 1917 times)

Traveler777

  • I post occasionally
  • **
  • Posts: 43
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.2
Drupal User Import - Duplicate Contact Created in CiviCRM
January 07, 2012, 06:21:57 pm
Hi All,

We are about to import CiviCRM contacts to Drupal (Drupal Import Module) to get them associated with a username and password.

During tests I noticed:

Instead of applying the Drupal ID to the already existing CiviCRM contact, it creates a new CiviCRM contact. The contact created during user import exists of the email and the Drupal ID.

Has anyone experienced this before and knows what's going wrong? Does it has something to do with the CiviCRM dupe check?

Thanks for any hints,
Traveler777

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Drupal User Import - Duplicate Contact Created in CiviCRM
January 07, 2012, 06:34:13 pm
I imported drupal users using migrate module & found that it created the users OK when the drupal mail matched exactly one civicrm email but there were a few where it couldnt' make the match (40 out of 1200) & created duplicates
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Traveler777

  • I post occasionally
  • **
  • Posts: 43
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.2
Re: Drupal User Import - Duplicate Contact Created in CiviCRM
January 07, 2012, 07:01:04 pm
Hi Eileen,

Just to clarify, did you use the migrate module to create Drupal users linked to CiviCRM contacts?

We already have our CiviCRM contacts (no need to import to CiviCRM for us), but need to establish the usernames and passwords for our CiviCRM contacts in Drupal so they can access content pages.

Thanks!




Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Drupal User Import - Duplicate Contact Created in CiviCRM
January 07, 2012, 07:01:57 pm
Yes I did - but I didn't do anything to make them link - I was going to - until I discovered it had 'just happened'
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Drupal User Import - Duplicate Contact Created in CiviCRM
January 07, 2012, 07:04:14 pm
This is the class I used - pretty messy with copy & paste - you'll see I didn't even rename it from the example module

Code: [Select]
<?php
class BeerUserMigration extends AbaCiviMigrate {
  public function 
__construct() {
    
// The basic setup is similar to BeerTermMigraiton
    
parent::__construct();
    
$this->description = t('ABA users');
    
$this->map = new MigrateSQLMap($this->machineName,
        array(
          
'id' => array(  'type' => 'int',
                          
'length' => 6,
                          
'not null' => TRUE,
                  
'description' => 'IMS contact ID',
          
'alias' => 'name',
                          )
        ),
        
MigrateDestinationCivicrmApi::getKeySchema()
      );
    
$query = db_select('ims.name', 'name')
             ->
fields('name', array('id',  'email','JOIN_DATE', 'first_name' ,'last_name' ))
             ->
condition('paid_thru', '2011-11-01', '>')
             ->
condition('email' ,'', '<>')
             ->
condition('member_type' ,'Ind');
    
$query->isNotNull('email'); 
    
$query->addExpression("CONCAT(first_name, last_name)",'username');
    
$this->source = new MigrateSourceSQL($query);
    
$this->destination = new MigrateDestinationUser();
    
$this->dependencies = array('AbaCiviMigrationContact');
    
// One good way to organize your mappings is in three groups - mapped fields,
    // unmapped source fields, and unmapped destination fields

    // Mapped fields

    // This is a shortcut you can use when the source and destination fields are
    // identical
    
$this->addFieldMapping('mail', 'email');

    
// Dedupe assures that value is unique. Use it when source data is non-unique.
    // Pass the Drupal table and column for determining uniqueness.
    
$this->addFieldMapping('name', 'username')
         ->
dedupe('users', 'name');

    
// The migrate module automatically converts date/time strings to UNIX timestamps.
    
$this->addFieldMapping('created', 'JOIN_DATE');
    
$this->addFieldMapping('pass', 'supersecret');
    
$this->addFieldMapping('domain_user',0);
     
$this->addFieldMapping('status')->defaultValue(1);   
    
// Instead of mapping a source field to a destination field, you can
    // hardcode a default value. You can also use both together - if a default
    // value is provided in addition to a source field, the default value will
    // be applied to any rows where the source field is empty or NULL.
   // $this->addFieldMapping('roles')
   //      ->defaultValue(2);
  //  $this->addFieldMapping('field_migrate_example_gender', 'sex');

    // The source field has beer names separated by a pipe character ('|'). By
    // adding ->separator('|'), the migration will automatically break them out,
    // look up the node with each title, and assign the node reference to this
    // user.
   // if (module_exists('node_reference')) {
 ////     $this->addFieldMapping('field_migrate_example_favbeers', 'beers')
 //          ->separator('|');
 //   }

    // Unmapped source fields
 //   $this->addFieldMapping(NULL, 'nickname')
   //      ->issueGroup(t('DNM'));

    // Unmapped destination fields

    // This is a shortcut you can use to mark several destination fields as DNM
    // at once
    
$this->addUnmigratedDestinations(array('theme', 'signature', 'access', 'login',
      
'timezone', 'language', 'picture', 'is_new'));


  }
   public function 
prepare($entity, $row){
    
  }
}
« Last Edit: January 07, 2012, 07:21:28 pm by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Traveler777

  • I post occasionally
  • **
  • Posts: 43
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.2
Re: Drupal User Import - Duplicate Contact Created in CiviCRM
January 07, 2012, 07:18:35 pm
Thanks Eileen. Will test this out.

In the meanwhile, if anyone else has any clue what could have gone wrong with the user import module let me know. It's all set up and ready to go, just the dupe issue.

Traveler777

  • I post occasionally
  • **
  • Posts: 43
  • Karma: 0
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.2
Re: Drupal User Import - Duplicate Contact Created in CiviCRM
January 09, 2012, 05:00:10 pm
Update for anyone who gets in the same situation as I did:

The solution was quite simple. Make sure that your "Strict" rule for "Individuals" is set to check for dupe emails ONLY.

CiviCRM Menu: Contacts > Find and Merge Duplicate Contacts

Thanks again Eileen for providing an alternative solution.

Traveler777

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Drupal User Import - Duplicate Contact Created in CiviCRM

This forum was archived on 2017-11-26.