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) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • activity get api broken? can't return results for a specific cid anymore?
Pages: [1]

Author Topic: activity get api broken? can't return results for a specific cid anymore?  (Read 654 times)

ericg

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.3.x - 4.5.x
  • CMS version: drupal 6 and 7
  • MySQL version: 5.1 and 5.5
  • PHP version: 4.3
activity get api broken? can't return results for a specific cid anymore?
April 15, 2015, 10:32:19 am
I added this as a bug in jira but figured I'd add it here as well in case someone knows a good workaround

https://issues.civicrm.org/jira/browse/CRM-16298

somewhere along the way between 4.3.x and 4.5.x the api changed and it is no longer possible to get activities of a specific type that are connected to a specific cid

here is the code I have in place that worked until I did an upgrade to 4.5.x

// looks to see if activity already exists

  $params_activity_check = array(
    'version' => 3,
    'sequential' => 1,
    'activity_type_id' => 50,
    'activity_date_time' => $visit_date,
    'source_contact_id' => $school_cid,
    );
  $result_activity_check = civicrm_api('activity', 'get', $params_activity_check);

  if ($result_activity_check['count'] ==0) {
// create the activity

it now brings back an array of every activity of that type, no matter what cid is associated.
this means that my code now needs to loop over the array which grows by thousands of activities each semester to find if the one I'm looking for exists. that seems very inefficient

the source_contact_id is still in the array returned, but can no longer be used in the get request. I hope this is a bug and not an intentional change.

based on the following unanswered issues in the forum, it seems I'm not the only one with this problem

http://forum.civicrm.org/index.php/topic,21685.msg90883.html#msg90883

http://forum.civicrm.org/index.php/topic,5548.msg24388.html#msg24388

http://forum.civicrm.org/index.php/topic,31672.msg135725.html#msg135725

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: activity get api broken? can't return results for a specific cid anymore?
April 15, 2015, 11:20:48 pm
The api did not change as far as I know, the core tables changed. As per 4.4 we no longer have the civicrm_activity_target and civicrm_activity_assignee tables and the source_contact_id is not longer in the table civicrm_activity. Instead we have a table called civicrm_activity_contact with a reciord_type_id where (out of the op of my head) 1= source, 2 = assignee and 3 = target (check in the option values if I am correct :-)). The api should deal with that, but you might have hit a bug. Can you try using the parameters
Code: [Select]
contact_id => $school_cid
record_type_id = 1

and see if that works for you?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • activity get api broken? can't return results for a specific cid anymore?

This forum was archived on 2017-11-26.