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) »
  • modify the default fields exported by API.contact (and export ?)
Pages: [1]

Author Topic: modify the default fields exported by API.contact (and export ?)  (Read 802 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
modify the default fields exported by API.contact (and export ?)
May 02, 2011, 12:06:58 am
Hi,

The default api.contact.get returns the following fields. I would like to simplify and that by default it doesn't return as many.


{
         "contact_id":"2",
         "contact_type":"Individual",
         "sort_name":"Parker, Sandy",
         "display_name":"Dr Sandy J Parker Jr",
         "do_not_email":"0",
         "do_not_phone":"1",
         "do_not_mail":"0",
         "do_not_sms":"0",
         "do_not_trade":"0",
         "is_opt_out":"0",
         "preferred_mail_format":"Both",
         "first_name":"Sandy",
         "middle_name":"J",
         "last_name":"Parker",
         "birth_date":"2010-10-15",
         "is_deceased":"1",
         "contact_is_deleted":"0",
         "gender_id":"2",
         "gender":"Male",
         "prefix_id":"4",
         "prefix":"Dr.",
         "suffix_id":"1",
         "suffix":"Jr.",
         "address_id":"83",
         "street_address":"862C Green St S",
         "supplemental_address_1":"Subscriptions Dept",
         "city":"Wallsburg",
         "postal_code":"84082",
         "geo_code_1":"40.371817",
         "geo_code_2":"-111.41809",
         "state_province_id":"1043",
         "state_province_name":"Utah",
         "state_province":"UT",
         "country_id":"1228",
         "country":"United States",
         "phone_id":"110",
         "phone_type_id":"1",
         "phone":"74847775",
         "worldregion_id":"2",
         "world_region":"America South, Central, North and Caribbean"
      },


Proposal (again in the "by default", can be requested by adding them in the return) to remove:


         "do_not_email":"0",
         "do_not_phone":"1",
         "do_not_mail":"0",
         "do_not_sms":"0",
         "do_not_trade":"0",
         "is_opt_out":"0",
         "preferred_mail_format":"Both",
         "is_deceased":"1",
         "contact_is_deleted":"0",
         "prefix_id":"4",
         "prefix":"Dr.",
         "suffix_id":"1",
         "suffix":"Jr.",
         "geo_code_1":"40.371817",
         "geo_code_2":"-111.41809",
         "worldregion_id":"2",
         "world_region":"America South, Central, North and Caribbean"


Rationale: it generates more expensive queries, take bandwidth and are arguably not very useful.
Moreover, I'd like that api user start using the return=first_name,last_name... More likely we will get the question "how to add a field", than "how to remove a field".

as for the contact_id, can we/how to work on the transition to have "id" instead ?

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: modify the default fields exported by API.contact (and export ?)
May 02, 2011, 12:37:58 am
Hi,

The default fields is a BAO function. Would be good to understand how that fits (are there cases where the BAO query returns too much too? Or is it the right fit).

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

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: modify the default fields exported by API.contact (and export ?)
May 02, 2011, 01:26:43 am
I agree it makes more sense to have less fields returned, but doesn't that mean we are moving away from the 'keep the API as stupid as is feasible'? But I have never been in a situation where I needed the fields....
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: modify the default fields exported by API.contact (and export ?)
May 02, 2011, 02:03:56 am
Well, trying to limit what is sent is rather going in the right direction, here the default is trying to accommodate everything.

Actually, we might (at least in debug mode) to add an "extra filter" with a list of rowCount, return, ... to give an idea to the user of what they are missing ?

X+

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

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: modify the default fields exported by API.contact (and export ?)
May 02, 2011, 02:05:44 am
Color me convinced then  ;)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: modify the default fields exported by API.contact (and export ?)
May 02, 2011, 02:50:34 am
Actually, I'm probably more in favour of leaving this because if it breaks people's code /makes it harder to migrate I don't think we have gained enough - given that we are encouraging people to pass in return fields anyway
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) »
  • modify the default fields exported by API.contact (and export ?)

This forum was archived on 2017-11-26.