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) »
  • Note API sort
Pages: [1]

Author Topic: Note API sort  (Read 1381 times)

jimurl

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 0
  • CiviCRM version: 3.4.6
  • CMS version: drupal 6.22
  • MySQL version: 5+
  • PHP version: 5+
Note API sort
November 28, 2011, 04:09:57 pm
Does the Note API support sorting? I am trying this with Smarty:

{crmAPI var="ContactNoteS" entity="Note" action="get" version="3" entity_id="$contactId" sort="modified_date DESC"}

In the api explorer on my site, I tried this:
/civicrm/ajax/rest?json=1&debug=on&entity=Note&action=get&sequential=1&sort=modified_date&entity_id=26196

but get this at the top of the results:
"is_error":0,
   "undefined_fields":["sort"],
   "version":3,
   "count":2,
   "values":[{
...
...



« Last Edit: November 30, 2011, 08:14:42 am by jimurl »

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Note API sort
November 28, 2011, 04:37:49 pm
It supports 'option.sort' or 'options' => array('sort');

(all the ones based on   _civicrm_api3_basic_get(); support that syntax).      
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

jimurl

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 0
  • CiviCRM version: 3.4.6
  • CMS version: drupal 6.22
  • MySQL version: 5+
  • PHP version: 5+
Re: Note API sort
November 29, 2011, 02:34:05 pm
that does work on the API explorer; but within a smarty template, this :

{crmAPI var="ContactNoteS" entity="Note" action="get" version="3" entity_id="$contactId" option.sort="modified_date DESC"}

is still not sorting them in reverse chronological order. Am I not referring to the sort member of the option array correctly?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Note API sort
November 30, 2011, 12:28:19 am
smarty has issues with dot in the names.

I think I implemented a workaround replacing with underscore. Can you try option_sort= ?

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

jimurl

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 0
  • CiviCRM version: 3.4.6
  • CMS version: drupal 6.22
  • MySQL version: 5+
  • PHP version: 5+
Re: API sort results syntax
November 30, 2011, 08:13:46 am
That was totally it! Thank to both of you. Here is what worked: option_sort="modified_date DESC"

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Note API sort
December 01, 2011, 06:19:01 am
Glad you sorted it out.

If you could modify the wiki and clarify if needed, that'd be useful for the other users.

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Note API sort

This forum was archived on 2017-11-26.