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 (Moderator: Donald Lobo) »
  • setting mult-select fields
Pages: [1]

Author Topic: setting mult-select fields  (Read 765 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
setting mult-select fields
March 26, 2010, 02:55:40 am
Can someone give me a pointer on setting 'advanced multiselect' custom fields through code. I can set normal custom fields with :    

Code: [Select]
$params = array('custom_138' =>"blah",'entityID=2);
$result = (CRM_Core_BAO_CustomValueTable::setValues($params));
a

but that doesn't set multi-select fields correctly and passing in an array or comma separated list doesn't either.

Code: [Select]
<?php
if (module_exists('civicrm')) {
  
civicrm_initialize(TRUE);
}
require_once 
'CRM/Core/BAO/CustomValueTable.php';
$params = array('custom_30' => array("blah" => 1 ),'entityID'=>2);
$result = (CRM_Core_BAO_CustomValueTable::setValues($params));
print_r($result);

?>

returns

Array ( [is_error] => 1 [error_message] => value: Array is not of the right field data type: String )
« Last Edit: March 26, 2010, 03:01:31 am by Eileen »
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

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: setting mult-select fields
March 26, 2010, 07:02:18 am
Eileen:

You might wanna try this :
Code: [Select]
$params = array('custom_138' =>CRM_Core_BAO_CustomOption::VALUE_SEPERATOR ."blah".CRM_Core_BAO_CustomOption::VALUE_SEPERATOR,
                             'entityID=2);
$result = (CRM_Core_BAO_CustomValueTable::setValues($params));

HTH
-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: setting mult-select fields
March 26, 2010, 01:12:37 pm
Thanks Yashoda. Is it possible to add things like this to the comments for a function - there seems to be a pretty tight format in use but it would be handy
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 (Moderator: Donald Lobo) »
  • setting mult-select fields

This forum was archived on 2017-11-26.