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) »
  • Using hook_civicrm_contactListQuery partially breaks quick search
Pages: [1]

Author Topic: Using hook_civicrm_contactListQuery partially breaks quick search  (Read 1102 times)

stuart

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 0
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 6
  • MySQL version: 5.0.77
  • PHP version: 5.3
Using hook_civicrm_contactListQuery partially breaks quick search
November 17, 2011, 05:59:04 am
I'm using hook_civicrm_contactListQuery to modify the quick search, by replacing the query where the context is navigation:

if ($context == 'navigation') {
    $query = "SELECT cc.id as id, CONCAT_WS( ' :: ', sort_name, email, phone, street_address, city, ste.name, coy.name ) as data
        FROM civicrm_contact cc LEFT JOIN civicrm_email eml ON ( cc.id = eml.contact_id AND eml.is_primary = 1 )
        LEFT JOIN civicrm_phone phe ON ( cc.id = phe.contact_id AND phe.is_primary = 1 )
        LEFT JOIN civicrm_address sts ON ( cc.id = sts.contact_id AND sts.is_primary = 1 )
        LEFT JOIN civicrm_state_province ste ON ( sts.state_province_id = ste.id )
        LEFT JOIN civicrm_country coy ON ( sts.country_id = coy.id )
        WHERE sort_name LIKE '%$name%' OR external_identifier = '$name'
        OR postal_code LIKE '%$name%' AND cc.is_deleted = 0
        LIMIT 0,10";
}

This works correctly to generate a different list for the quick search, and you can click a specific result in the dropdown list. However, if you simply type in the quick search and hit enter, you get a backtrace with the error:

Sorry. A non-recoverable error has occurred.
cid (value: ) is not of the type Positive

It seems to still be using the overwritten query for this search, but expects a single value back. If I search for something where I know there's only one result, it works, but any other time it fails.Is there a way to specify a different query for the quick search list and the quick search form behaviour?
« Last Edit: January 12, 2012, 03:51:24 am by stuart »

stuart

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 0
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 6
  • MySQL version: 5.0.77
  • PHP version: 5.3
Re: Using hook_civicrm_contactListQuery partially breaks quick search
January 16, 2012, 05:45:18 am
I haven't been able to find a solution to the issue, if anyone has any suggestions.

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Using hook_civicrm_contactListQuery partially breaks quick search
January 16, 2012, 10:03:01 am
I have checked on my local 3.4.8 install and seems to be working fine. Is there a specific sequence to replicate this?

Kurund
Found this reply helpful? Support CiviCRM

stuart

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 0
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 6
  • MySQL version: 5.0.77
  • PHP version: 5.3
Re: Using hook_civicrm_contactListQuery partially breaks quick search
January 26, 2012, 04:10:10 am
Thanks Kurund - I upgraded from 3.4.4 to 3.4.8 and it started working!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Using hook_civicrm_contactListQuery partially breaks quick search

This forum was archived on 2017-11-26.