Answers.Body: <p>I think I might have figured out what's going on here... The tables that are trying to be used in the view have been created after the table details were taken from <em>sites/all/modules/civicrm/install/index.php</em> and pasted into 
   the <em>settings.php</em> file (which was done initially when configuring the system).  So when the new tables are created they do not exist in the settings.php file (I'm unsure whether CiviCRM should do this by default or not), but if I go in and update the settings.php file with the new mapping it seems to address the issue and Drupal then looks in the correct database.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-22T15:27:16.183Z
Answers.Text: That's correct.  If you create a new custom field set and want to use it in Views then you will need to update `settings.php` to add the new table.
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-22T12:05:15.203Z
Answers.LastActivityDate: 2017-11-22T12:05:15.203Z
Answers.UserDisplayName: Mo-ster
Body: <p>I have an instance of drupal 7 installed… and it is storing its data in database A
  I have then installed CiviCRM… and it is storing its data in database B</p>
  
  <p>I have placed the information shown at sites/all/modules/civicrm/install/index.php in to the settings.php file … so the CiviCRM tables can be seen and found.  Also, the base URL is set correctly in the civicdm.settings.php file.</p>
  
  <p>Now when I go to create a view… </p>
  
  <ol>
  <li>I select “Add a view” and specify a name for the view (the view
  is of type page); </li>
  <li>then i select CiviCRM Contacts from the Show
  drop-down list…</li>
  <li>decide on the display format and then click
  continue and edit to get to the screen to add the fields as
  required.  </li>
  <li>On the view creation screen I have added the field
  <strong>CiviCRM Contacts: First Name</strong> and that shows correctly with no errors</li>
  <li>but when I try adding the <strong>CiviCRM Contacts: Contact Sub Type</strong>
  field to the Filter Criteria section (or the Fields section for that
  matter)  I get the following error message:</li>
  </ol>
  
  <blockquote>
    <p>Error Message states (<em>some info substituted with generic information</em>):
    <strong>SQLSTATE[42S02]: Base table or view not found: 1146 Table</strong>
    ‘&lt;<em>user_which_created_drupal_database</em>>.&lt;<em>drupal_pre-fix</em>><strong>_civicrm_value_</strong>&lt;‘<em>civicrm</em>
    <em>custom field postfix</em>> <strong>doesn't exist</strong>’</p>
  </blockquote>
  
  <p><strong>By the looks of things, the filter criteria section of the view is looking to the Drupal database</strong> for the CiviCRM table for the subtype field - <strong>which it obviously won’t find as the table is actually in the CiviCRM database (Database B)</strong>.  A similar situation occurs if I try to add the sub-type field into the 'Fields' sections of the view creation process.</p>
  
  <p>Sounds like this is a configuration issue (E.g Views is looking in the Drupal database and not the CiviCRM database - but yet it does look in the correct database when looking up the Contacts Name) - anyone got any ideas or had this happen to them before, looking for a solution.</p>
  
Tags: <drupal><custom-fields><database><drupal-views>
Title: Drupal Views Filtering on Subtype
ThreadText: # Drupal Views Filtering on Subtype
  
  (Asked by: username_0 on 2017-11-22)
  
  I have an instance of drupal 7 installed… and it is storing its data in database A
  I have then installed CiviCRM… and it is storing its data in database B
  
  I have placed the information shown at sites/all/modules/civicrm/install/index.php in to the settings.php file … so the CiviCRM tables can be seen and found. Also, the base URL is set correctly in the civicdm.settings.php file.
  
  Now when I go to create a view…
  
  1. I select “Add a view” and specify a name for the view (the view
     is of type page);
  2. then i select CiviCRM Contacts from the Show
     drop-down list…
  3. decide on the display format and then click
     continue and edit to get to the screen to add the fields as
     required.
  4. On the view creation screen I have added the field
     **CiviCRM Contacts: First Name** and that shows correctly with no errors
  5. but when I try adding the **CiviCRM Contacts: Contact Sub Type**
     field to the Filter Criteria section (or the Fields section for that
     matter) I get the following error message:
  
  > Error Message states (*some info substituted with generic information*):
  > **SQLSTATE[42S02]: Base table or view not found: 1146 Table**
  > ‘<*user\_which\_created\_drupal\_database*>.<*drupal\_pre-fix*>**\_civicrm\_value\_**<‘*civicrm*
  > *custom field postfix*> **doesn't exist**’
  
  **By the looks of things, the filter criteria section of the view is looking to the Drupal database** for the CiviCRM table for the subtype field - **which it obviously won’t find as the table is actually in the CiviCRM database (Database B)**. A similar situation occurs if I try to add the sub-type field into the 'Fields' sections of the view creation process.
  
  Sounds like this is a configuration issue (E.g Views is looking in the Drupal database and not the CiviCRM database - but yet it does look in the correct database when looking up the Contacts Name) - anyone got any ideas or had this happen to them before, looking for a solution.
  
  **Tags:** drupal, custom-fields, database, drupal-views
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-11-22. Score: 4
  
  I think I might have figured out what's going on here... The tables that are trying to be used in the view have been created after the table details were taken from *sites/all/modules/civicrm/install/index.php* and pasted into
  the *settings.php* file (which was done initially when configuring the system). So when the new tables are created they do not exist in the settings.php file (I'm unsure whether CiviCRM should do this by default or not), but if I go in and update the settings.php file with the new mapping it seems to address the issue and Drupal then looks in the correct database.
  
  > **Comments:**
  > **username_1**: That's correct.  If you create a new custom field set and want to use it in Views then you will need to update `settings.php` to add the new table.  
  
  ---
  
  