Answers.Body: <p>Mattermost: <a href="https://chat.civicrm.org/civicrm/pl/swpdndm5y3yxmj1yq5my64aq8h" rel="nofollow noreferrer">https://chat.civicrm.org/civicrm/pl/swpdndm5y3yxmj1yq5my64aq8h</a></p>
  <p>The comment helped solved my issue. Thank you!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-18T19:45:30.870Z
Answers.Text: Thanks for answering your own question but could you edit this to include the actual solution in your answer so that people don't need to click the link to find it. This also means that your answer will still be helpful even if the link no longer works.
Answers.UserDisplayName: William Mortada
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-17T03:59:25.887Z
Answers.LastActivityDate: 2024-07-17T03:59:25.887Z
Answers.UserDisplayName: darkmode
Body: <p>Is it possible to modify query for quicksearch? <code>hook_civicrm_contactListQuery</code> is no longer being called so query cannot be modified.</p>
  <p>I tried apiWrapper hook but I am not sure how to make filter like below there.</p>
  <p>Scenario:</p>
  <p>Being able to search a contact name in quicksearch with &quot;Name/Email&quot; option/filter selected. I understand that we can change/update sort_name format in Display preference, then contact sort_name will now be updated when contact details is edited/updated.</p>
  <p>However, since there are many contacts already, we want to just add a where clause to filter them.</p>
  <p>In mysql, we can do</p>
  <pre><code>&quot;WHERE (CONCAT(last_name, ' ', first_name) LIKE '%exchange stack%')&quot;
  </code></pre>
  <p>Is this somehow possible in with apiWrapper hook? Or other hook that can do it.</p>
  <p>I also tried the <code>civi.search.autocompleteDefault</code> hook where I added <code>CONCAT(last_name, ' ', first_name)</code> in <code>savedSearch[&quot;api_params&quot;][&quot;select&quot;]</code> and use <code>HAVING</code>, but it does not work.</p>
  <p>Mattermost: <a href="https://chat.civicrm.org/civicrm/pl/ccuywbjzwi8ppg53oa9w3ryq3r" rel="nofollow noreferrer">https://chat.civicrm.org/civicrm/pl/ccuywbjzwi8ppg53oa9w3ryq3r</a></p>
  
Tags: <quicksearch>
Title: QuickSearch Custom Query
ThreadText: # QuickSearch Custom Query
  
  (Asked by: username_0 on 2024-07-17)
  
  Is it possible to modify query for quicksearch? hook_civicrm_contactListQuery is no longer being called so query cannot be modified.
  I tried apiWrapper hook but I am not sure how to make filter like below there.
  Scenario:
  Being able to search a contact name in quicksearch with "Name/Email" option/filter selected. I understand that we can change/update sort_name format in Display preference, then contact sort_name will now be updated when contact details is edited/updated.
  However, since there are many contacts already, we want to just add a where clause to filter them.
  In mysql, we can do
  "WHERE (CONCAT(last_name, ' ', first_name) LIKE '%exchange stack%')"
  
  Is this somehow possible in with apiWrapper hook? Or other hook that can do it.
  I also tried the civi.search.autocompleteDefault hook where I added CONCAT(last_name, ' ', first_name) in savedSearch["api_params"]["select"] and use HAVING, but it does not work.
  Mattermost: https://chat.civicrm.org/civicrm/pl/ccuywbjzwi8ppg53oa9w3ryq3r
  
  **Tags:** quicksearch
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-07-17. Score: 2
  
  Mattermost: <https://chat.civicrm.org/civicrm/pl/swpdndm5y3yxmj1yq5my64aq8h>
  
  The comment helped solved my issue. Thank you!
  
  > **Comments:**
  > **username_1**: Thanks for answering your own question but could you edit this to include the actual solution in your answer so that people don't need to click the link to find it. This also means that your answer will still be helpful even if the link no longer works.  
  
  ---
  
  