1

It appears that the Contact GetCount API is not working properly in 4.4 to retrieve group counts. I can code around it by switching to Get which works fine, but wanted to see if there was something I was missing. (I'm upgrading from a 4.2.6 site which works fine.) My specific example is a smart group, but I've tried non-smart groups as well with the same result.

Using the api/explorer ....

On my 4.4.19 test site

The GetCount is wrong

/civicrm/ajax/rest?json=1&sequential=1&debug=1&&entity=Contact&action=getcount&group=82 returns { "is_error":0, "result":1 }

But the get is right /civicrm/ajax/rest?/civicrm/ajax/rest?entity=Contact&action=get&debug=1&sequential=1&json=17&group=82 returns ... "count":9, ....

But on my 4.2.6 live site

The GetCount and Get are both correct

/civicrm/ajax/rest?json=1&sequential=1&debug=1&&entity=Contact&action=getcount&group=82 returns { "is_error":0, "result":8 }

/civicrm/ajax/rest?/civicrm/ajax/rest?entity=Contact&action=get&debug=1&sequential=1&json=17&group=82 returns .... "count":8,

  • I can see the getCount returning correct result on the 44 demo site d44.demo.civicrm.org. Checked for /civicrm/ajax/rest?json=1&sequential=1&debug=1&&entity=Contact&action=getcount&group=3 – jitendra - fuzion Oct 6 '15 at 5:45
  • That returns { "is_error":0, "result":5474 } which is the full count of my contact list no matter what group ID I include. – Anne Savage Oct 6 '15 at 12:12
1

I have just checked the API call in Civi 4.4 installation and the getcount with the group parameter on Contact does not work.

Also the API call on GroupContact does not work either. What you could do is probably write a small extension which includes a getcount api for Group memberships.

  • 1
    Thanks. As mentioned below in the conversation with ErikH, I switched to Get rather than GetCount. That works well enough for my needs - it's in a spot which is used only occasionally. – Anne Savage Nov 5 '15 at 13:18
0

That error does not ring a bell to me and we use CiviCRM 4.4 (and the API) quite a lot. As Jitendra already tried on the demo site I will give it a try on one of my installs...and the getcount on the contact works perfectly in the API explorer?

  • That's really odd. All my tests are only in the api explorer. And as described above, in 4.4 count works, getcount doesn't. I don't know what could be wrong/different on my install since it's the api explorer. Hmm. – Anne Savage Oct 6 '15 at 12:16
  • Is there any customization on your installation that might touch the underlying BAO functions? Obiously it should not....but just to be sure to be sure :-) – ErikH - CiviCooP Oct 6 '15 at 12:27
  • Good question, but no. To be sure I deleted custom code and templates directories and uninstalled custom modules. Flushed all caches and retested. No change in behavior. Thanks for the suggestion. At this point I've re-coded and will use get. Not ideal but it works. – Anne Savage Oct 6 '15 at 14:27
  • Weird though :-( – ErikH - CiviCooP Oct 6 '15 at 14:53

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.