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) »
  • Update Custom Check Box with API
Pages: [1]

Author Topic: Update Custom Check Box with API  (Read 679 times)

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Update Custom Check Box with API
February 07, 2012, 01:14:37 pm
What is the format for updating a check box via the API? I have 3 checkboxes:

Youth - 1
Women - 2
Seniors - 3

I have tried:

custom_8 = 1

in the params setting, which does update the database. When I view the custom field, it even shows Youth, but if I search for Youth after no results are returned unless I change the custom field to Youth in the GUI. Any thoughts?

Also, how would I format it if I wanted to check multiple boxes - say I wanted both 1 & 2 selected?

Brian


Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Update Custom Check Box with API
February 07, 2012, 02:55:33 pm
Hi,

It's either because you need to wrap separator strings around it

function _civicrm_api3_separate_values( &$values )

does that - it may have been added after your version? & if the api should call it. So it may be an upgrade will help.

Otherwise you might need to set your array as

custom_8 => array ( 1 => 1; 3 => 1 ); for youth, seniors


http://svn.civicrm.org/civicrm/branches/v4.0/api/v3/utils.php
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

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Update Custom Check Box with API
February 07, 2012, 03:41:17 pm
Thanks Eileen. Don't know why I didn't think to try the array, but it worked perfectly

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

This forum was archived on 2017-11-26.