Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-15905

API: problem sorting contacts on ID

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.5.5, 4.6
    • Fix Version/s: 4.6
    • Component/s: CiviCRM API
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      I wanted to retrieve the most recently added contacts using the API. I did it like this:

      $result = civicrm_api3('Contact', 'get', array(
      'sequential' => 1,
      'options' => array('sort' => "id DESC"),
      ));

      I got an error message, because id was ambiguous. It seems I could work around the problem this way:

      $result = civicrm_api3('Contact', 'get', array(
      'sequential' => 1,
      'options' => array('sort' => "contact_a.id DESC"),
      ));

      But I think it would be better if an unqualified sort field would be applied to the entity that is retrieved.

        Attachments

          Activity

            People

            • Assignee:
              monish.deb Monish Deb
              Reporter:
              johanv Johan Vervloet
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: