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) »
  • Using API to retrieve Contact records by modified_date?
Pages: [1]

Author Topic: Using API to retrieve Contact records by modified_date?  (Read 1417 times)

nicolas

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 6
    • cividesk
  • CiviCRM version: 4.4 LTS
  • CMS version: Standalone (yep)
  • MySQL version: 5.1
  • PHP version: 5.3
Using API to retrieve Contact records by modified_date?
December 23, 2011, 10:47:41 pm
[repost in the right forum]
I need to retrieve the list of contacts modified since a certain date, or a list of contacts ordered by modified_date desc. Is there a simple way to do that with the API v3? If not, is it easy to add to existing Contacts API (just point me in the right direction and I will do it)? If neither of the above, is that type of request built into the Contact BAO/DAO? If none of these works, I will hack a SQL query together ...

Thanks.
cividesk -- CiviCRM delivered ... your way!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Using API to retrieve Contact records by modified_date?
December 24, 2011, 05:29:36 am
Hi,

It might exist already (the api is exposing what the BAO does). You could check what is the name of the field in the advanced search and see if it works as a param (using the api explorer).

We are trying to move away of introducing new "pseudo fields" so if you were to introduce a new by modification date, please use filter.modified_date = array ('>' => '2011-10-10');

http://svn.civicrm.org/civicrm/trunk/api/v3/examples/Address/AddressLike.php

The code for the api is into api/v3/Contact.php (function civicrm_api3_contact_get).
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

nicolas

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 6
    • cividesk
  • CiviCRM version: 4.4 LTS
  • CMS version: Standalone (yep)
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Using API to retrieve Contact records by modified_date?
December 24, 2011, 12:39:05 pm
Thanks Xavier, after looking through the  Contact Search (Advanced) form the following seems to work:

$params = array(
      'version' => 3,
      'log_date'     => '2',  // cf. Contacts Search (Advanced) form, 1: created, 2: modified
      'log_date_low' => 'mm/dd/yyyy',
);
$return = civicrm_api( 'Contact', 'get', $params );
cividesk -- CiviCRM delivered ... your way!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Using API to retrieve Contact records by modified_date?
December 25, 2011, 12:57:31 pm
Great,

could you add it to the wiki?

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

nicolas

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 6
    • cividesk
  • CiviCRM version: 4.4 LTS
  • CMS version: Standalone (yep)
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Using API to retrieve Contact records by modified_date?
December 25, 2011, 09:25:43 pm
Xavier - I'm actually planning to contribute an update the whole API documentation with detailed principles and usage examples. Eileen has proposed to facilitate a meeting with the API team so I can gather needed materials to do so. She will do that as soon as she returns from the beach (her own words!), so probably next week.
cividesk -- CiviCRM delivered ... your way!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Using API to retrieve Contact records by modified_date?
December 26, 2011, 06:50:17 am
Hi,

It will be very welcomed and she mentioned it indeed.

Are you already on  IRC and what's your account?

Also, you might want to join our list  (civicrm-api@lists.civicrm.org) for the occasional interesting discussion and more common exchange of bad jokes ;)

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

bouton

  • Guest
Re: Using API to retrieve Contact records by modified_date?
December 28, 2011, 04:27:45 am
Nicholas
Thanks for that api call.
Any idea how I would get the the last modified date back as a returned field? I tried using your params with a return=log_date_low or return=modified_date but with no luck
« Last Edit: December 28, 2011, 05:28:41 am by bouton »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Using API to retrieve Contact records by modified_date?

This forum was archived on 2017-11-26.