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) »
  • How to assign values to custom fields in Activity programatically
Pages: [1]

Author Topic: How to assign values to custom fields in Activity programatically  (Read 887 times)

rubofvil

  • I’m new here
  • *
  • Posts: 23
  • Karma: 1
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 7
  • MySQL version: mysql 5.1
  • PHP version: php 5.2
How to assign values to custom fields in Activity programatically
March 27, 2013, 02:34:12 am
How to assign values to custom fields in Activity programatically?

I don't have problems to create Activity with API. But i don't find the way to assign values to values in custom field of  Activity.

I don't know if the correct way is investigate CRM_Core_BAO_CustomValueTable
Code: [Select]
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_activity', $result->id);(in civicrm 4.2 CRM/Activity/BAO/Activity.php line 555).
And generate var $params.

Thanks for any reply.

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: How to assign values to custom fields in Activity programatically
March 27, 2013, 04:33:14 am
Does this help? http://wiki.civicrm.org/confluence/display/CRMDOC43/API+Reference#APIReference-CustomData
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: How to assign values to custom fields in Activity programatically
March 27, 2013, 09:24:37 pm
I'm not against the wiki or book, but for this type of thing I tend to lean towards the unit tests as a good source:
http://svn.civicrm.org/civicrm/trunk/tests/phpunit/api/v3

See also http://en.wikipedia.org/wiki/Unit_testing#Documentation

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: How to assign values to custom fields in Activity programatically
March 31, 2013, 12:15:59 pm
Both links are good. Also, adding onto demeritcowboy's link, we now have a fancier way for linking to code, e.g.

https://github.com/civicrm/civicrm-core/blob/4.3.beta5/tests/phpunit/api/v3/ActivityTest.php#L505

The example is a little verbose (but hopefully obvious) -- instead of saying 'custom_' . $ids['custom_field_id'] one would usually just say 'custom_123'

rubofvil

  • I’m new here
  • *
  • Posts: 23
  • Karma: 1
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 7
  • MySQL version: mysql 5.1
  • PHP version: php 5.2
Re: How to assign values to custom fields in Activity programatically
April 02, 2013, 10:46:12 am
I try to use the API with "entity" directly with ajax/doc, but I don't advance too much.

I don't know about folder with examples, test/phpunit/api, lot of thanks. This saves me too much time. :)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How to assign values to custom fields in Activity programatically

This forum was archived on 2017-11-26.