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) »
  • Setting custom data via hook
Pages: [1]

Author Topic: Setting custom data via hook  (Read 1298 times)

leapywca

  • Guest
Setting custom data via hook
November 18, 2009, 01:17:12 pm
We have written a custom module for our non profit as well as a few hooks for it.  We have a custom data field in a case activity that we would like to set via a custom hook.  We checked the box "view only" in the GUI for that data field but can't figure out how to set that field based on the contents of another field.  (For example if the BMI data field has 23.5 entered in the text box then the hook would populate the BMI category field with "Normal").  We've been trying to figure out how to find the name of that form element to reference it in the hook (we have the $form object and printed it with print_r) , but we could not find any documentation or examples regarding how this is accomplished. Any input/suggestions/examples would be greatly appreciated.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Setting custom data via hook
November 18, 2009, 02:55:39 pm

all custom fields are of the form:

custom_XXX

where XXX is the field ID from the DB

Dont have any handy examples which use that hook currently. But the above should get you started :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Setting custom data via hook
November 30, 2009, 05:37:45 am
You can also see the html code on the edit form. the name of the fields contains the ID of the custom field (easier than having to find it in the DB I think).

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

ijames

  • Guest
Re: Setting custom data via hook OR SOAP?
December 16, 2009, 01:59:50 am
UPDATE:  I have started this as a new topic here: 

http://forum.civicrm.org/index.php/topic,11316.0.html


Hi,

I've setup the SoapServer.php to communicate with CiviCRM using the APIs.

It's all working pretty well, except for the custom fields on the activity.  When I try to set the custom fields, it was erroring out, on the SOAP until I noticed the below:

custom_XXX.  I had been using custom_XX as is the way it seems to work in contact fields.

So my params are now custom_XXX and it seems to work, but it doesn't seem to set the values on the custom fields.

In other words, via SOAP, I'm calling:

civicrm_activity_create
« Last Edit: December 16, 2009, 01:24:19 pm by ijames »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Setting custom data via hook

This forum was archived on 2017-11-26.