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) »
  • Importing data using API - stateProvince from name?
Pages: [1]

Author Topic: Importing data using API - stateProvince from name?  (Read 1634 times)

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Importing data using API - stateProvince from name?
September 02, 2013, 02:07:56 am
I've got some legacy data which needs importing into CiviCRM, and it includes CiviCase components so it seems I can't use the GUI import process. Instead, I thought I could write a script to use the API to load the contacts, their relationships and create the case details all in one process. However, I can't see how to import the stateProvince using the the API - is there a method for looking up the text string of an address and converting it into the stateProvince id so that it can be inserted into the address table entry?


Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Importing data using API - stateProvince from name?
September 02, 2013, 02:57:54 pm
I think that if you put a state name in the state_province_id field it will do the lookup for you
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

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: Importing data using API - stateProvince from name?
September 04, 2013, 02:53:25 am
Hi Eileen,

Thanks, but that's not my experience with the API explorer.

I went with:


              $stateProvinces=civicrm_api("Constant","get", array ('version' =>'3', 'name' =>'stateProvince'));             
              $county = array_search($graphic2_import_array['15'], $stateProvinces['values']);


... and then insert the $county variable into the address,create API call.

Seems to work. But it feels a bit clunky.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Importing data using API - stateProvince from name?

This forum was archived on 2017-11-26.