1

Right now I am using the API Explorer (in 4.7.21) just to get the pieces I need for some custom code in Drupal. I am just very confused about what the API Explorer is returning. I am guessing this me not a bug.

If I execute the following with the Case ID of 223 then I should get back the contact assigned to that case.

$result = civicrm_api3('CaseContact', 'get', array(
  'sequential' => 1,
  'return' => array("contact_id"),
  'id' => 223,
)); 

When I execute this I get the contact for case 224.

If I use the API to query for the Subject of the case for ID 223 I get the expected results and the same for 224.

$result = civicrm_api3('Case', 'get', array(
  'sequential' => 1,
  'return' => array("subject"),
  'id' => 223,
));

If anyone sees my error here I would appreciate it. If this is a bug I am glad to put it only issues.civicrm.org.

Thanks!

1

It should be 'case_id' => 223 instead of 'id' => 223 for the CaseContact one. It seems to work with either on the public demo, but that might be coincidence - in the civicrm_case_contact table the 'id' field is an autoincrement technically unrelated to case_id, but may or may not match the case_id depending on creation order, multiple clients, and other happenings.

I would use 'case_id', like so

$result = civicrm_api3('CaseContact', 'get', array( 'sequential' => 1, 'return' => array("contact_id"), 'case_id' => 223, ));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.