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) »
  • Get contacts in smart group.
Pages: [1]

Author Topic: Get contacts in smart group.  (Read 1093 times)

SweetTooth

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 1
  • CiviCRM version: 4.1
  • CMS version: Drupal 6.20
  • MySQL version: 5.1.54
  • PHP version: 5.2.17
Get contacts in smart group.
October 21, 2012, 07:15:09 am

Hello,

I wish to have data returned from the API that just returns the contacts in a smart group.

What would I need to stick in my $params array to achieve that?

Thanks!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Get contacts in smart group.
October 22, 2012, 07:20:48 am
civicrm_api ("contact","get",array ("group"=> 42,version=>3));

should do it. try first on api explorer.

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

SweetTooth

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 1
  • CiviCRM version: 4.1
  • CMS version: Drupal 6.20
  • MySQL version: 5.1.54
  • PHP version: 5.2.17
Re: Get contacts in smart group.
October 23, 2012, 06:15:38 am
Quote from: xavier on October 22, 2012, 07:20:48 am
civicrm_api ("contact","get",array ("group"=> 42,version=>3));

should do it. try first on api explorer.

X+

Thanks! I'll give that a shot and report back.



jcasharpe

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 5
    • Woodlands Church
  • CiviCRM version: 4.4.6
  • CMS version: Drupal 7
  • MySQL version: MariaDB 10.0.13
  • PHP version: 5.5
Re: Get contacts in smart group.
November 27, 2012, 02:39:00 pm
For reference this should be:
civicrm_api ("GroupContact","get",array ("group_id"=> 42,version=>3));

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Get contacts in smart group.
November 27, 2012, 03:07:09 pm
Actually - reading this just reminded me - there are some mystery smarts in the call Xavier described - did you try it?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

SweetTooth

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 1
  • CiviCRM version: 4.1
  • CMS version: Drupal 6.20
  • MySQL version: 5.1.54
  • PHP version: 5.2.17
Re: Get contacts in smart group.
December 02, 2012, 06:12:36 am

It worked for me!

I can't remember why I wanted it or what I used it for!

 :o

noah

  • I’m new here
  • *
  • Posts: 18
  • Karma: 4
Re: Get contacts in smart group.
December 19, 2012, 01:31:41 pm
Using this API call gets me contacts who were manually added to the group. It does not get me "smart" contacts:

/civicrm/ajax/rest?json=1&sequential=1&debug=1&entity=GroupContact&action=get&group_id=69&rowCount=300
« Last Edit: December 19, 2012, 02:35:45 pm by noah »

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: Get contacts in smart group.
December 19, 2012, 03:32:00 pm

There is no API for this in 4.2 . We've made some progress towards this in 4.3, but not yet exposed via the API

you can get all contacts for a smart group via a call lik:

http://drupal.demo.civicrm.org/civicrm/ajax/rest?json=1&sequential=1&debug=1&entity=contact&action=get&group=2&rowCount=70

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Get contacts in smart group.

This forum was archived on 2017-11-26.