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) »
  • Import fails if Employer (or other Related Contact) is left blank
Pages: [1]

Author Topic: Import fails if Employer (or other Related Contact) is left blank  (Read 1869 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Import fails if Employer (or other Related Contact) is left blank
February 10, 2011, 06:54:23 pm
Hi,

I'm continuing a conversation on an older thread that had gone stale: http://forum.civicrm.org/index.php/topic,16187.msg69161.html

Here's the problem ...
  • Import contacts in update mode with an employer column, which includes empty cells (not every contact has an employer that we know of)
  • Set the mapping for that column to match the employing Organisation's name
  • During the import, all rows with an empty employer cell will be rejected with the message 'Related contact required fields are missing.'

IMHO, the row should not be rejected, but processed without creating an employer.

On the topic quoted above, Kiran seemed to acknowledge the problem, so I haven't verified this on the demo site.

That thread ended with Kiran asking for an issue to be raised. I don't have enough PHP to supply a robust patch, but I can suggest what's needed.

I refer you to the 3.3.5 version code for CRM/Import/Parser/Contact.php.

Lines 791-798 contain the logic for deciding whether to throw this error ...

Code: [Select]
                    //do we have enough fields to create related contact.
                    $allowToCreate = $this->checkRelatedContactFields( $key, $formatting );
                   
                    if ( !$allowToCreate ) {
                        $errorMessage = ts( 'Related contact required fields are missing.' );
                        array_unshift($values, $errorMessage);
                        return CRM_Import_Parser::NO_MATCH;
                    }

I can't understand checkRelatedContactFields() but I think it needs to be rewritten (it's only used here for this purpose). That function needs to distinguish three cases:

  • no Related Contact data was supplied (silently skip the creation of the relationship)
  • insufficient Related Contact data (report an error)
  • sufficient Related Contact data (attempt to create the relationship)

If case 2 never occurs, then the code can be simplified to not return an error but to skip the creation of the Related Contact relationship.

Ken

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: Import fails if Employer (or other Related Contact) is left blank
February 11, 2011, 07:09:26 am

hey ken:

thanx for the analysis

can you please file an issue and link to this post. We'll take a look at it for a future release (4.1 or so). import is fairly complex, but we do need to restructure, clean and optimize it in some future version

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

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Import fails if Employer (or other Related Contact) is left blank
February 11, 2011, 01:02:14 pm
Created issue CRM-7540

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Import fails if Employer (or other Related Contact) is left blank

This forum was archived on 2017-11-26.