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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Creating contacts with id
Pages: [1]

Author Topic: Creating contacts with id  (Read 309 times)

huulbaek

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.5.2
  • CMS version: WordPress
  • MySQL version: x
  • PHP version: x
Creating contacts with id
October 21, 2014, 02:05:00 am
Hi! :)

I'm trying to create a lot of new contacts with the API - it's an import from our obsolete member database. Because I want the contact_id to match the id's in our financial system, I want to create them with the same id. However, that will only try to update an existing record, right?

Is there any way where I could get a create call working with an id - like in the parameters below? It throws an error but all is ok if I omit the id.

Code: [Select]
$params = array(
'id' => $excel_id,
'first_name' => $first_name,
'last_name' => $last_name,
'contact_type' => 'Individual',
'street_address' => $full_address,
'preffered_language' => 'da_DK',
'custom_6' => $kommune,
);

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Creating contacts with id
October 21, 2014, 02:07:04 am
If you want to keep old ids you need to create some dummy records via sql - which you can then alter via the import (& then at the end delete all the ones that still have your dummy values if you haven't done exactly the right ids)
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

huulbaek

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.5.2
  • CMS version: WordPress
  • MySQL version: x
  • PHP version: x
Re: Creating contacts with id
October 21, 2014, 04:32:20 am
Thank you, Eileen, that worked out fine. :)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Creating contacts with id

This forum was archived on 2017-11-26.