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) »
  • Custom fields not working with Relationship API
Pages: [1]

Author Topic: Custom fields not working with Relationship API  (Read 1595 times)

ruid

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 4
Custom fields not working with Relationship API
June 28, 2009, 08:19:48 pm
I am trying to add custom fields to Relationship through Relationship API.
This is a piece of my codes for adding a relationship:
Code: [Select]
$relationship_params = array(
'contact_id_a'         => $data['contact_a'],
'contact_id_b'         => $data['new_branch_id'],
'relationship_type_id' => $this->relationship_type_id,
'start_date'           => array('d'=>$r_end_date[0],'M'=>$r_end_date[1],'Y'=>$r_end_date[2]),
'is_active'            => 1,
'custom_56'            => "test custom field"
);

$new_relationship = & civicrm_relationship_create( $relationship_params );

The custom field wasn't added through this params. I have gone through the api/v2/Relationship.php compared with Contact.php and found there is a line in Contact.php
Code: [Select]
_civicrm_custom_format_params( $params, $values, $params['contact_type'], $entityId );
looks like formating the custom data not in Relationship.php.

Is this a small bug in Relationship API?

Another issue about Relationship API is it doesn't allow me to add same relationship type to same contacts but it allow me to do it in CiviCRM UI. I have to comment
Code: [Select]
93    $duplicate++;
94    continue;
in CRM/Contact/BAO/Relationship.php to avoid duplicate check for adding new relationship. Is there supposed to be a duplicate check for relationship?

Matt2000

  • I post frequently
  • ***
  • Posts: 288
  • Karma: 27
    • http://www.ninjitsuweb.com
Re: Custom fields not working with Relationship API
June 30, 2009, 05:31:16 pm
I vaguely recall the same issue with the custom fields. It may be a bug. Have you check JIRA?
Drupal/CiviCRM micro-blogging http://twitter.com/matt2000

Ninjitsu Web Development http://www.NinjitsuWeb.com/

ruid

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 4
Re: Custom fields not working with Relationship API
June 30, 2009, 11:33:06 pm
I checked JIRA but can't find any issue about custom data in relationship API. :(

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: Custom fields not working with Relationship API
July 01, 2009, 06:36:07 am

hey ruid:

can u please file an issue along with a small test file that exercises and demonstrates the problem

thanx

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

ruid

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 4
Re: Custom fields not working with Relationship API
July 01, 2009, 06:46:55 pm
Hi Lobo

I have filed an issue.
http://issues.civicrm.org/jira/browse/CRM-4696

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: Custom fields not working with Relationship API
July 13, 2009, 12:00:12 am
ruid:

Issue is fixed, here is the patch (http://fisheye.civicrm.org/changelog/CiviCRM?cs=22447)

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

ruid

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 4
Re: Custom fields not working with Relationship API
July 13, 2009, 04:35:35 pm
Thank you very much.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Custom fields not working with Relationship API

This forum was archived on 2017-11-26.