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) »
  • civicrm_contact_relationship_get return value of 'Invalid Data'
Pages: [1]

Author Topic: civicrm_contact_relationship_get return value of 'Invalid Data'  (Read 1572 times)

hlevinson

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 3
civicrm_contact_relationship_get return value of 'Invalid Data'
November 30, 2009, 12:55:39 pm
While using the API function civicrm_contact_relationship_get, I noticed that if it doesn't find relationships of the requested type it returns the string 'Invalid Data'.

Certainly I can test for this particular string, but I'm wondering:

Is this a standard response for this kind of outcome when using an API function? If so, there's nothing that needs changing.

It might make more sense to return an empty string, or some other string such as 'No relationships found'. The current message made me think I submitted invalid input data.

To see what I'm talking about, do a call to the function with a valid contact_id (change to something that makes sense for your db) for a contact that has no employer, e.g.:

Code: [Select]
$params = array(
'contact_id' => 145,
);

$result = &civicrm_contact_relationship_get($params, array(), array('Employee of'));


xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: civicrm_contact_relationship_get return value of 'Invalid Data'
December 01, 2009, 10:48:04 pm
Hi,

I think what you are using is obsoleted. The one that certainly works on the REST interface is civicrm_relationship_get

http://wiki.civicrm.org/confluence/display/CRMDOC/Relationship+APIs#RelationshipAPIs-civicrmrelationshipget%28%26%24params%29

This being said, I think the result is going to be the same.

Invalid Data isn't a good status return for this case indeed IMO. But that'd be tricky to change.

In general the "warning", "error" or other status messages aren't very well defined and it should be something easier to parse than a text message (on some other we provide an is_error flag+msg error). The other problem is that the message is translated.

If you have any suggestion, feel free...

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • civicrm_contact_relationship_get return value of 'Invalid Data'

This forum was archived on 2017-11-26.