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) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions (Moderator: Dave Greenberg) »
  • Last modified time
Pages: [1]

Author Topic: Last modified time  (Read 954 times)

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Last modified time
April 27, 2014, 06:10:20 pm
A client developer is working on NationBuilder integration and wants to be able to compare data from both systems. They asked "how do I see the modification timestamp of a contact record via CiviCRM API?"

I don't think we offer it currently, but I can see it's available via querying civicrm_log - max(modified_date) where entity_table='civicrm_contact' and entity_id = :entity_id.

I suggested that we might add an optional flag to API calls to retrieve that value and attach it to the API result if required.

  • Is there a better way they could approach this?
  • Are there existing API methods to check how current the data on a contact record is? (I don't see them in the API explorer.)
  • Would contact.mtime be much use anyway? I'd think you'd want contact.phone.mtime not just contact.mtime since having recently donated doesn't make the phone record any more current ...
@xurizaemon ● www.fuzion.co.nz

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Last modified time
May 01, 2014, 07:20:17 am
I've hacked this feature into our client's 4.3 branch - doesn't apply cleanly to CiviCRM master but it will probably be easy enough to drop in. Will test and review it tomorrow with our client.

I found Query.php a bit hard to make sense of and reckon I've added code somewhere it might not ordinarily live. Feedback welcome :)

Patch for 4.3 @ https://gist.githubusercontent.com/xurizaemon/c792897ebc9e5b73dc85/raw/628daf34c4fa40c8b1a28b5669fc694baf2ce657/civicrm-last_modified.patch
@xurizaemon ● www.fuzion.co.nz

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Last modified time
May 01, 2014, 07:27:26 am
Hi,

On 4.4, there is a created_date and modified_date fields (I think it's a sql trigger that updates it, or at least I've had some bugs on something related)

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

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Last modified time
May 01, 2014, 08:00:11 am
Thanks Xavier. Great news, glad it exists.

Should it be exposed via API? I don't see it at api/explorer on demo (4.4.6 currently)

 http://drupal.demo.civicrm.org/civicrm/api/explorer#/civicrm/ajax/rest?entity=Contact&action=get&debug=1&sequential=1&json=1
@xurizaemon ● www.fuzion.co.nz

capo

  • I post occasionally
  • **
  • Posts: 108
  • Karma: 5
Re: Last modified time
May 08, 2014, 04:57:59 am
I'm having exactly the same problem! I need to "synchronise" the CiviCRM database with a second one and, to do so, I need to access via API the contacts that have been modified since a certain date and time.

Chris, I totally agree these two fields should be exposed via API. Plus, it would be nice if they supported "<", ">", "<=", etc. operators, so we could make calls like:

Code: [Select]
?entity=Contact&action=get&debug=1&sequential=1&json=1&modified_date[>]20140508133000

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Last modified time
May 08, 2014, 05:29:14 am
I'll get around to filling issue and patch on this, it's a very minor change. Tomorrow. Thanks for the nudge :)
@xurizaemon ● www.fuzion.co.nz

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Last modified time
May 08, 2014, 07:31:14 pm
https://issues.civicrm.org/jira/browse/CRM-14596 has the PR for this. You'll need to rebuild your DAO (php GenCode.php) to expose it.
@xurizaemon ● www.fuzion.co.nz

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions (Moderator: Dave Greenberg) »
  • Last modified time

This forum was archived on 2017-11-26.