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

API contact.get group='x' yields ""DB Error: no such field""

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7.15, 4.7.16, 4.7.17
    • Fix Version/s: 4.7.17
    • Component/s: None
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code
    • Verified?:
      No

      Description

      On http://dmaster.demo.civicrm.org/civicrm/api#explorer, define criteria such that this is the PHP form of the API call:

      $result = civicrm_api3('Contact', 'get', array(
        'debug' => 1,
        'sequential' => 1,
        'group' => "Administrators",
      ));
      

      Observe this failure:

      {
      
          "error_code": "no such field",
          "trace": "#0 [internal function]: CRM_Core_Error::exceptionHandler(Object(DB_Error))\n#1 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/PEAR.php(921): call_user_func(Array, Object(DB_Error))\n#2 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/DB.php(985): PEAR_Error->__construct('DB Error: no su...', -19, 16, Array, 'SELECT contact_...')\n#3 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/PEAR.php(575): DB_Error->__construct(-19, 16, Array, 'SELECT contact_...')\n#4 [internal function]: PEAR->_raiseError(Object(DB_mysqli), NULL, -19, NULL, NULL, 'SELECT contact_...', 'DB_Error', true)\n#5 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/PEAR.php(224): call_user_func_array(Array, Array)\n#6 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->__call('raiseError', Array)\n#7 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -19, NULL, NULL, 'SELECT contact_...', 'DB_Error', true)\n#8 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-19, NULL, NULL, NULL, '1054 ** Unknown...')\n#9 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()\n#10 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery('SELECT contact_...')\n#11 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/DB/DataObject.php(2438): DB_common->query('SELECT contact_...')\n#12 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/DB/DataObject.php(1627): DB_DataObject->_query('SELECT contact_...')\n#13 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/DAO.php(354): DB_DataObject->query('SELECT contact_...')\n#14 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/DAO.php(1304): CRM_Core_DAO->query('SELECT contact_...', true)\n#15 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(4391): CRM_Core_DAO::executeQuery('SELECT contact_...')\n#16 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/api/v3/utils.php(574): CRM_Contact_BAO_Query::apiQuery(Array, NULL, NULL, NULL, 0, 25, NULL, NULL, 0, 1, 'Contact')\n#17 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/api/v3/Contact.php(164): _civicrm_api3_get_using_query_object('Contact', Array, Array)\n#18 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_contact_get(Array)\n#19 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/Civi/API/Kernel.php(169): Civi\\API\\Provider\\MagicFunctionProvider->invoke(Array)\n#20 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/Civi/API/Kernel.php(100): Civi\\API\\Kernel->runRequest(Array)\n#21 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/api/api.php(23): Civi\\API\\Kernel->runSafe('Contact', 'get', Array, NULL)\n#22 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Utils/REST.php(404): civicrm_api('Contact', 'get', Array)\n#23 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Utils/REST.php(641): CRM_Utils_REST::process(Array, Array)\n#24 [internal function]: CRM_Utils_REST::ajax()\n#25 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Invoke.php(276): call_user_func(Array)\n#26 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem(Array)\n#27 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke(Array)\n#28 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke(Array)\n#29 [internal function]: civicrm_invoke('ajax', 'rest')\n#30 /srv/buildkit/build/dmaster/includes/menu.inc(527): call_user_func_array('civicrm_invoke', Array)\n#31 /srv/buildkit/build/dmaster/index.php(21): menu_execute_active_handler()\n#32 {main}",
          "is_error": 1,
          "error_message": "DB Error: no such field"
      }
      

      With this bug in place, I can think of no API method to get members of a smart group (as I understand it GroupContact is no good for smart groups).

      Marking as Major with the understanding that APIs and Smart Groups are major features. Please adjust priority as appropriate.

      Also labeling as Regression; I don't have a version handy in which this worked, but this at least indicates it once did: http://civicrm.stackexchange.com/questions/10399/how-to-retrieve-all-contacts-belonging-to-a-smart-group

        Attachments

          Activity

            People

            • Assignee:
              seamuslee Seamus Lee
              Reporter:
              allenshaw Allen Shaw
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: