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) »
  • address and phone can't be chained on contact creation/update?
Pages: [1]

Author Topic: address and phone can't be chained on contact creation/update?  (Read 1845 times)

fen

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 13
    • CivicActions
  • CiviCRM version: 3.3-4.3
  • CMS version: Drupal 6/7
  • MySQL version: 5.1/5.5
  • PHP version: 5.3/5.4
address and phone can't be chained on contact creation/update?
October 10, 2011, 01:57:33 pm
When I create a new user (or update an existing one) information in api.email.create gets used correctly, but api.phone.create and api.address.create both silently fail.  I'm assuming these chains just haven't been implemented yet (and I haven't figured out where to look yet) but here is the failing params array passed in civicrm_api('Contact','create',@params):
Code: [Select]
Array
(
    [version] => 3
    [contact_type] => Individual
    [first_name] => Doc
    [last_name] => Watson
    [api.phone.create] => Array
        (
            [0] => Array
                (
                    [phone] => 800-555-1212
                    [phone_type_id] => 261
                    [location_type_id] => 3
                )

        )
    [api.address.create] => Array
        (
            [0] => Array
                (
                    [street_address] => 1 Infinite Loop
                    [city] => Cupertino
                    [postal_code] => 94014
                    [location_type_id] => 2
                    [country_id] => 1228
                    [is_primary] => 1
                )

        )
    [id] => 54321
    [contact_id] => 54321
)

Am I doing something wrong?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: address and phone can't be chained on contact creation/update?
October 10, 2011, 02:41:08 pm
Hi,

Should work by removing one level (the 0) in the api calls:

[api.phone.create] => Array
        (
         
                    [phone] => 800-555-1212
                    [phone_type_id] => 261
                    [location_type_id] => 3
         
        )
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

fen

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 13
    • CivicActions
  • CiviCRM version: 3.3-4.3
  • CMS version: Drupal 6/7
  • MySQL version: 5.1/5.5
  • PHP version: 5.3/5.4
Re: address and phone can't be chained on contact creation/update?
October 10, 2011, 02:49:24 pm
Quote from: xavier on October 10, 2011, 02:41:08 pm
Should work by removing one level (the 0) in the api calls:

Thanks for the reply, but I must admit it seems odd as email and website both take the extra level, and all (email, website, phone and address) can have multiple values (e.g., home and work phones).

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: address and phone can't be chained on contact creation/update?
October 10, 2011, 02:55:39 pm
So, multiple values isn't something we've really implemented & the standard is that API shouldn't support it - but some might....

I do think at some point we will have a standard for multiple values but it's more likely to be implemented in the wrapper than the apis so those that do support it are probably, technically, wrong. (although we have to respect any functionality that works & try to keep it working )
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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: address and phone can't be chained on contact creation/update?
October 10, 2011, 10:23:33 pm
Quote from: fen on October 10, 2011, 02:49:24 pm
Thanks for the reply, but I must admit it seems odd as email and website both take the extra level, and all (email, website, phone and address) can have multiple values (e.g., home and work phones).

api.email.create and api.website.create can have multiple values with 0,1..? Could you post the complete example?

As eileen said, not completely defined how that's supposed to work. We might have a chained api that works both with a single level of attributes or an array of attributes in all cases down the line (did I mention that patches are welcome ? ;)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: address and phone can't be chained on contact creation/update?
October 11, 2011, 12:42:42 am
Actually - I just checked the tests & we have 2 tested syntaxes - including the one you first tried. I set them to generate examples which you can now find

http://svn.civicrm.org/civicrm/branches/v3.4/api/v3/examples/Contact

Not sure why your phone didn't work - did you print the output?

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: address and phone can't be chained on contact creation/update?
October 11, 2011, 03:50:23 am
Hi,

Cool, wasn't sure it both syntax were already working. Magic!

You can add a debug=> true param, that should be a bit more verbose

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: address and phone can't be chained on contact creation/update?
October 11, 2011, 01:17:22 pm
Yep - couldn't remember what I'd done but I HAD written a test. It's almost enough to encourage me to re-engage with the tests again :-) (but not, actually enough - I figure if other people are putting them in their too-hard basket - http://issues.civicrm.org/jira/browse/CRM-8950- I need to learn that lesson)
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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • address and phone can't be chained on contact creation/update?

This forum was archived on 2017-11-26.