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) »
  • Location API problem
Pages: [1]

Author Topic: Location API problem  (Read 3124 times)

ruid

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 4
Location API problem
March 08, 2009, 04:53:58 pm
I am using Location API to add new locations to contacts. However, the address and phone number can not be added as primary.

Below is the print_r of my API param array:

Array ( [contact_id] => 6470
        [location_type] => Work
        [phone] => Array (
                          [1] => Array (
                                        [phone] => 12345678
                                        [phone_type] => Phone
                                        [is_primary] => 1 )
                          [2] => Array (
                                        [phone] => 23456789
                                        [phone_type] => Mobile ) )
        [email] => Array ( [1]=> Array (
                                         [email] => myname@mydomain.com.au ) )
        [street_address] => 96 Smith St
        [supplemental_address_1] =>
        [city] => TestCity
        [postal_code] => 1234
        [state_province] => TestProvince
        [country] =>
        [is_primary] => 1 )

After this, the phone number, address, email are not primary. IE, when search this contact, the result page doesn't show Address, City, Phone, Email etc.

Is there anything wrong in my param array? I can't find any information about this in the Location API doc page.

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Location API problem
March 08, 2009, 10:17:47 pm
hi,

It would be good if you update your forum profile with CiviCRM, CMS, MySQL, PHP versions.
Quote
I am using Location API to add new locations to contacts.
Which Location API are you using ?

If you are running latest stable CiviCRM ( v2.1.6 ).
You might want to take a look for location api test cases.
go to tests/BAO/Core/Location.test line around 135 testAddLocationOrganizationWithAddressEmail( );

kiran
You Are Designed To Choose... Defined By Choice.

ruid

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 4
Re: Location API problem
March 09, 2009, 04:42:20 pm
Thanks for your help kiran.

I am using 2.1.6 and the v2 API. All the information I can find is this page http://wiki.civicrm.org/confluence/display/CRMDOC/Location+APIs.

I look at my files but can't find tests folder. Can you please point me out where to do find the test files?

Rui

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Location API problem
March 09, 2009, 10:10:45 pm
Quote
I look at my files but can't find tests folder. Can you please point me out where to do find the test files?

http://svn.civicrm.org/civicrm/trunk/tests/api/v2/LocationAdd.test

Kurund
« Last Edit: March 09, 2009, 10:12:43 pm by Kurund Jalmi »
Found this reply helpful? Support CiviCRM

ruid

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 4
Re: Location API problem
March 11, 2009, 05:24:37 pm
Thanks Kurund.

However, compared with the Params in LocationAdd.test. I can't find any difference to my Params. Address, City, Phone, Email etc. are still not primary.

I am trying to upgrade to 2.2. Hopefully it will fix this issue.

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Location API problem
March 12, 2009, 03:21:41 am
hi

Code: [Select]
             $params = array(  'contact_id' => 6470,
                               'location_type'  => 'Work',
                               'phone'  => array( array ( 'phone' => 12345678,
                                                          'phone_type' => 'Phone',
                                                          'is_primary' => 1 ),
                                                  array ( 'phone' => 23456789,
                                                          'phone_type' => 'Mobile' ) ),
                                'email'  => array ( array ( 'email' => 'myname@mydomain.com.au' ) ),
                                'street_address'  => '96 Smith St',
                                'supplemental_address_1'  => '',
                                'city'  => 'TestCity',
                                'postal_code'  => 1234,
                                'state_province'  => 'TestProvince',
                                'country' => '',
                                'is_primary' => 1 );
       
             require_once 'api/v2/Location.php';
             $location = & civicrm_location_add($params);

this $params format is working fine for my local install of v2.1.6 ( latest stable release )

kiran
You Are Designed To Choose... Defined By Choice.

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

This forum was archived on 2017-11-26.