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) »
  • Retrieving/modifying data in custom fields
Pages: [1]

Author Topic: Retrieving/modifying data in custom fields  (Read 815 times)

trevorwood

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 4
  • CiviCRM version: 4.0.2
  • CMS version: Joomla 1.6
  • MySQL version: 5.0.51a
  • PHP version: 5.2.6-1+lenny8
Retrieving/modifying data in custom fields
July 22, 2011, 04:56:09 am
I've created a couple of custom fields, one to attach to individual records and one to attach to organization record.

using the "civicrm_api( 'contact','get',$params )" function I can get the standard data but how do I get the data from the custom field?

also - I've created a group and added an organization to it. How do i retrieve all organisations for a specified group?

cheers
« Last Edit: July 22, 2011, 05:46:08 am by trevorwood »

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Retrieving/modifying data in custom fields
July 22, 2011, 02:49:30 pm
try adding

'return.custom_11' => 1

to your params

(where 11 is the field id).

Note that you may have to specify other return fields that were previously returned by default. Using 'return' makes for more efficient queries
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: Retrieving/modifying data in custom fields
July 23, 2011, 11:23:58 pm
Pretty sûre return Array ( custom_11,sortname...) works too. If it doesn't it Will.

Filtering : contact_type=Organization,group=42
-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: Retrieving/modifying data in custom fields
July 24, 2011, 12:20:37 am
X - We need some tests / test generated examples around your alternate return string. I don't feel confident using it yet
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

trevorwood

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 4
  • CiviCRM version: 4.0.2
  • CMS version: Joomla 1.6
  • MySQL version: 5.0.51a
  • PHP version: 5.2.6-1+lenny8
Re: Retrieving/modifying data in custom fields
July 27, 2011, 02:58:47 am
Quote from: Eileen on July 22, 2011, 02:49:30 pm
try adding

'return.custom_11' => 1

to your params

(where 11 is the field id).

Note that you may have to specify other return fields that were previously returned by default. Using 'return' makes for more efficient queries

Thanks, that works. Is this documented somewhere as it's going to make things a lot easier & clearer in my code

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Retrieving/modifying data in custom fields
July 27, 2011, 03:27:27 am
http://drupal.demo.civicrm.org/civicrm/ajax/doc --  if you choose a  'getfields'  function it should show you the custom fields amongst others.

I can't see the return functionality documented here yet - feel free to add it! I believe we are moving towards 'return' => array('display_name', 'id') - but not yet sure it that works across the API or not

http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
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

trevorwood

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 4
  • CiviCRM version: 4.0.2
  • CMS version: Joomla 1.6
  • MySQL version: 5.0.51a
  • PHP version: 5.2.6-1+lenny8
Re: Retrieving/modifying data in custom fields
July 27, 2011, 04:04:02 am
Interestingly, by using the return.fieldname some of the fields don't return

specifically when getting contact information, the state_province_name stops being retrieved. I can't get the state_province_name_id either so I've now had to do 2 retrieves. One to gett he custom field and one to get everything else

oh well, such is life. At least I can retrieve what i need now

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Retrieving/modifying data in custom fields

This forum was archived on 2017-11-26.