Answers.Body: <p>You can use Search API with CiviCRM Entity
  If you have CiviCRM tables in a separate database than Drupal tables, you need this PR: <a href="https://github.com/eileenmcnaughton/civicrm_entity/pull/450" rel="nofollow noreferrer">https://github.com/eileenmcnaughton/civicrm_entity/pull/450</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-23T22:53:03.043Z
Answers.Text: Many thanks - I initially misunderstood but it looks like all I need to do is add the $databases['civicrm']['default'] into my drupal settings file.  Looks like it's indexing but I'll have to wait and see.  I'll update this if I have configured it correctly.
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-25T00:04:57.937Z
Answers.Text: Everything indexed fine (it took a long time due to the size of the database) so I'll look at the rest of the solution.
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-23T21:58:59.590Z
Answers.LastActivityDate: 2024-02-23T21:58:59.590Z
Answers.UserDisplayName: jackrabbithanna
Body: <p>I need to update a Drupal 10 Webform so that it allows the user to pick a school in our database by name <strong>and/or</strong> postcode.  This is because there are a very large number of schools with very similar names e.g. St Mary's ..., and the autocomplete or Select list will not do the job.  We end up with the wrong school selected.</p>
  <p>I already have an existing Drupal View that does this for internal use, but I'd like to incorporate this functionality without the limitations of linking to this View and using a result link to return to the form with a contact ID for the Existing Contact i.e. I stay on the form to give the best user experience.</p>
  <p>I came across this old blog <a href="https://civicrm.org/blog/jackrabbithanna/civicrm-entity-using-drupal-search-and-facet-apis-with-civicrm-data" rel="nofollow noreferrer">Using Drupal Search and Facet APIs with CiviCRM Data</a> and in principle this approach, updated for D10, would seem to be the answer?</p>
  <p>Our CiviCRM and Drupal Databases are separate.  When I add the database server and indices I get a PHP exception:</p>
  <pre><code>Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal_dev.civicrm_address' doesn't exist:
  </code></pre>
  <p>For D7 you had to include in <code>settings.php</code> a section with all the CiviCRM tables, but this is no longer the case with CiviCRM Entity.</p>
  <p>So my questions are:</p>
  <ol>
  <li>Should I use the Drupal Search API approach as broadly outlined in the old blog and if not, what's the best way?</li>
  <li>Is my environment set up properly re the <code>settings.php</code> - you no longer get a list of tables?</li>
  </ol>
  <p>I can imagine this is not an uncommon use case, so hoping the answer to my question will benefit lot of people that the original blog was aimed at but are upgrading Drupal from 7 to 10.</p>
  
Tags: <webform-civicrm><civicrm-entity>
Title: Can I use Drupal 10 Search API?
ThreadText: # Can I use Drupal 10 Search API?
  
  (Asked by: username_0 on 2024-02-23)
  
  I need to update a Drupal 10 Webform so that it allows the user to pick a school in our database by name **and/or** postcode. This is because there are a very large number of schools with very similar names e.g. St Mary's ..., and the autocomplete or Select list will not do the job. We end up with the wrong school selected.
  
  I already have an existing Drupal View that does this for internal use, but I'd like to incorporate this functionality without the limitations of linking to this View and using a result link to return to the form with a contact ID for the Existing Contact i.e. I stay on the form to give the best user experience.
  
  I came across this old blog [Using Drupal Search and Facet APIs with CiviCRM Data](https://civicrm.org/blog/username_1/civicrm-entity-using-drupal-search-and-facet-apis-with-civicrm-data) and in principle this approach, updated for D10, would seem to be the answer?
  
  Our CiviCRM and Drupal Databases are separate. When I add the database server and indices I get a PHP exception:
  
  ```
  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal_dev.civicrm_address' doesn't exist:
  
  ```
  
  For D7 you had to include in `settings.php` a section with all the CiviCRM tables, but this is no longer the case with CiviCRM Entity.
  
  So my questions are:
  
  1. Should I use the Drupal Search API approach as broadly outlined in the old blog and if not, what's the best way?
  2. Is my environment set up properly re the `settings.php` - you no longer get a list of tables?
  
  I can imagine this is not an uncommon use case, so hoping the answer to my question will benefit lot of people that the original blog was aimed at but are upgrading Drupal from 7 to 10.
  
  **Tags:** webform-civicrm, civicrm-entity
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-02-23. Score: 2 | Accepted answer
  
  You can use Search API with CiviCRM Entity
  If you have CiviCRM tables in a separate database than Drupal tables, you need this PR: <https://github.com/eileenmcnaughton/civicrm_entity/pull/450>
  
  > **Comments:**
  > **username_0**: Many thanks - I initially misunderstood but it looks like all I need to do is add the $databases['civicrm']['default'] into my drupal settings file.  Looks like it's indexing but I'll have to wait and see.  I'll update this if I have configured it correctly.  
  > **username_0**: Everything indexed fine (it took a long time due to the size of the database) so I'll look at the rest of the solution.  
  
  ---
  
  