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) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • API 'contact get' strangeness when searching by 'state_province'
Pages: [1]

Author Topic: API 'contact get' strangeness when searching by 'state_province'  (Read 538 times)

Laryn

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 4
    • CEDC
  • CiviCRM version: 4.6.x
  • CMS version: Drupal 7
API 'contact get' strangeness when searching by 'state_province'
February 21, 2013, 07:06:53 am
*Thanks Eileen for the pointer to CRM_Contact_BAO_Query when I mentioned my issue on IRC.

Here's what I've found:
  • Using API/AJAX explorer, if you try to do a 'contact get' and filter by state_province, results do not come in as expected. (e.g. We have multiple DC addresses, but adding '&state_province=DC' yields 0 results and no error)
  • In CRM_Contact_BAO_Query (within CRM/Contact/BAO/Query.php), the following code is around line 618:
Code: [Select]
              if ($name == 'state_province') {
                $this->_select[$name] = "civicrm_state_province.abbreviation as `$name`, civicrm_state_province.name as state_province_name";
                $this->_element['state_province_name'] = 1;
              }
  • This seems to be using 'state_province_name' instead of 'state_province' (abbrev) so I tested in the AJAX Explorer and it works to add '&state_province=District of Columbia

This seems like a bug -- correct?

L.
CEDC...social justice by design

*Get support on the new CiviCRM help site. /laryn

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API 'contact get' strangeness when searching by 'state_province'
February 21, 2013, 03:26:12 pm
Is it a bug or a feature....

It's certainly not a easily predictable pattern. If it's fixed it needs to be fixed @ the BAO level & have the relevant details added to the _apiv3_contact_get_spec () function & preferably a unit test added - so if you have any desire to supply a patch for all of that...
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

Laryn

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 4
    • CEDC
  • CiviCRM version: 4.6.x
  • CMS version: Drupal 7
Re: API 'contact get' strangeness when searching by 'state_province'
February 25, 2013, 03:26:39 pm
Quote from: Eileen on February 21, 2013, 03:26:12 pm
Is it a bug or a feature....

It's certainly not a easily predictable pattern. If it's fixed it needs to be fixed @ the BAO level & have the relevant details added to the _apiv3_contact_get_spec () function & preferably a unit test added - so if you have any desire to supply a patch for all of that...

What's your sense -- is it worth fixing? For my purposes, now that I understand it I can use it, but I agree, it's not easily predictable for others who may be looking to do the same. On the other hand, "fixing it" could break a few sites that may rely on it as is?

L.
CEDC...social justice by design

*Get support on the new CiviCRM help site. /laryn

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • API 'contact get' strangeness when searching by 'state_province'

This forum was archived on 2017-11-26.