Answers.Body: <p>Drupal Views need to know about table updates when they are using separate databases.  When you add a custom field, civicrm  creates a new table.  To expose the new entity, you must edit the settings.php file with the new field.  You can just copy/paste from here: <a href="https://example.org/civicrm/admin/setting/uf?reset=1" rel="nofollow noreferrer">https://example.org/civicrm/admin/setting/uf?reset=1</a> .  Ref: <a href="https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/" rel="nofollow noreferrer">https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-10T11:39:12.683Z
Answers.Text: I don't think this is always the case. You only need to edit the settings.php file when a new custom field set is created, not for every new custom field. CivicRM only creates a new table for each custom field set, not for each custom field.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-10T02:20:14.013Z
Answers.Text: Would you care to edit your answer to reflect fact that the settings.php factor is only required if you have civi tables and drupal tables in different DBs
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-07-08T19:17:43.507Z
Answers.LastActivityDate: 2023-05-12T08:51:01.380Z
Answers.LastEditDate: 2023-05-12T08:51:01.380Z
Answers.UserDisplayName: Sonicthoughts
Body: <p>I have a Drupal View that I'm using to display in a directory a list of individuals that are employed by a group of organizations. I saw no way to filter a View based on employer names so I created a select list whereas I simply added as select options the organizations whose employees I wanted to display.</p>
  
  <p>At first I created this list to be used for 'All Contact Types' and it worked fine. I built a Drupal webform so people could edit there own information and that's when I found that the fields did not autopopulate with the current information. I assumed this was because the fields were user for all contact types and not for only individuals. I built a new custom data set that is used only for individuals and tried that. The Drupal webform would then show current information when the user logged in.</p>
  
  <p>I then realized that I could no longer filter the View with the new fields. When I used the old fields that were allowed for all contacts the filtering worked and I had individuals show in my directory, however, when I switched to the newly created fields that were limited to individuals I has no contact show in my directory.</p>
  
  <p>I've also run a preview within the View itself and only get results when using the custom field built for contacts. When using the one built for individuals I get no results. Any thoughts? The query is: </p>
  
  <blockquote>
    <p>SELECT DISTINCT civicrm_contact.id AS id, civicrm_contact.contact_type
    AS civicrm_contact_contact_type, civicrm_contact.display_name AS
    civicrm_contact_display_name, civicrm_contact.organization_name AS
    civicrm_contact_organization_name, civicrm_contact.job_title AS
    civicrm_contact_job_title, civicrm_email.email AS civicrm_email_email,
    civicrm_phone.phone AS civicrm_phone_phone, civicrm_contact.sort_name
    AS civicrm_contact_sort_name FROM {civicrm_contact} civicrm_contact
    LEFT JOIN {civicrm_value_testing_for_directory_25}
    civicrm_value_testing_for_directory_25 ON civicrm_contact.id =
    civicrm_value_testing_for_directory_25.entity_id LEFT JOIN
    {civicrm_email} civicrm_email ON civicrm_contact.id =
    civicrm_email.contact_id AND (civicrm_email.location_type_id = '2' AND
    civicrm_email.is_primary = '1') LEFT JOIN {civicrm_phone}
    civicrm_phone ON civicrm_contact.id = civicrm_phone.contact_id AND
    (civicrm_phone.location_type_id = '2' AND civicrm_phone.is_primary =
    '1') WHERE (( (civicrm_value_testing_for_directory_25.nhp_org_191 LIKE
    '%a%' OR civicrm_value_testing_for_directory_25.nhp_org_191 LIKE
    '%b%' ) )) ORDER BY civicrm_contact_sort_name ASC LIMIT 20 OFFSET 0</p>
  </blockquote>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-16T19:00:40.203Z
Comments.Text: Have you updated your settings.php file since creating the new custom fields?
Comments.UserDisplayName: pmoz
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-16T20:19:30.970Z
Comments.Text: The settings.php factor is only required if you have civi tables and drupal tables in different DBs
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-17T12:01:46.493Z
Comments.Text: I do have them in different databases and the settings.php file was updated long ago to reflect that. I can add other fields to the View and it works fine. Do you need to update the settings.php file every time you add custom fields? I've only modified it once.
Comments.UserDisplayName: spinsheet
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-17T12:30:44.180Z
Comments.Text: I just noticed that, yes, I need to go back in and edit the settings.php file when I add custom fields. I added the fields and it's now working. Thanks!
Comments.UserDisplayName: spinsheet
Tags: <drupal><drupal-views>
Title: Drupal View filtered with a custom individual data field
ThreadText: # Drupal View filtered with a custom individual data field
  
  (Asked by: username_0 on 2015-06-16)
  
  I have a Drupal View that I'm using to display in a directory a list of individuals that are employed by a group of organizations. I saw no way to filter a View based on employer names so I created a select list whereas I simply added as select options the organizations whose employees I wanted to display.
  
  At first I created this list to be used for 'All Contact Types' and it worked fine. I built a Drupal webform so people could edit there own information and that's when I found that the fields did not autopopulate with the current information. I assumed this was because the fields were user for all contact types and not for only individuals. I built a new custom data set that is used only for individuals and tried that. The Drupal webform would then show current information when the user logged in.
  
  I then realized that I could no longer filter the View with the new fields. When I used the old fields that were allowed for all contacts the filtering worked and I had individuals show in my directory, however, when I switched to the newly created fields that were limited to individuals I has no contact show in my directory.
  
  I've also run a preview within the View itself and only get results when using the custom field built for contacts. When using the one built for individuals I get no results. Any thoughts? The query is:
  
  > SELECT DISTINCT civicrm\_contact.id AS id, civicrm\_contact.contact\_type
  > AS civicrm\_contact\_contact\_type, civicrm\_contact.display\_name AS
  > civicrm\_contact\_display\_name, civicrm\_contact.organization\_name AS
  > civicrm\_contact\_organization\_name, civicrm\_contact.job\_title AS
  > civicrm\_contact\_job\_title, civicrm\_email.email AS civicrm\_email\_email,
  > civicrm\_phone.phone AS civicrm\_phone\_phone, civicrm\_contact.sort\_name
  > AS civicrm\_contact\_sort\_name FROM {civicrm\_contact} civicrm\_contact
  > LEFT JOIN {civicrm\_value\_testing\_for\_directory\_25}
  > civicrm\_value\_testing\_for\_directory\_25 ON civicrm\_contact.id =
  > civicrm\_value\_testing\_for\_directory\_25.entity\_id LEFT JOIN
  > {civicrm\_email} civicrm\_email ON civicrm\_contact.id =
  > civicrm\_email.contact\_id AND (civicrm\_email.location\_type\_id = '2' AND
  > civicrm\_email.is\_primary = '1') LEFT JOIN {civicrm\_phone}
  > civicrm\_phone ON civicrm\_contact.id = civicrm\_phone.contact\_id AND
  > (civicrm\_phone.location\_type\_id = '2' AND civicrm\_phone.is\_primary =
  > '1') WHERE (( (civicrm\_value\_testing\_for\_directory\_25.nhp\_org\_191 LIKE
  > '%a%' OR civicrm\_value\_testing\_for\_directory\_25.nhp\_org\_191 LIKE
  > '%b%' ) )) ORDER BY civicrm\_contact\_sort\_name ASC LIMIT 20 OFFSET 0
  
  **Tags:** drupal, drupal-views
  
  > **Comments:**
  > **username_1**: Have you updated your settings.php file since creating the new custom fields?  
  > **username_2**: The settings.php factor is only required if you have civi tables and drupal tables in different DBs  
  > **username_0**: I do have them in different databases and the settings.php file was updated long ago to reflect that. I can add other fields to the View and it works fine. Do you need to update the settings.php file every time you add custom fields? I've only modified it once.  
  > **username_0**: I just noticed that, yes, I need to go back in and edit the settings.php file when I add custom fields. I added the fields and it's now working. Thanks!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2015-07-08. Score: 2
  
  Drupal Views need to know about table updates when they are using separate databases. When you add a custom field, civicrm creates a new table. To expose the new entity, you must edit the settings.php file with the new field. You can just copy/paste from here: <https://example.org/civicrm/admin/setting/uf?reset=1> . Ref: <https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/>
  
  > **Comments:**
  > **username_2**: Would you care to edit your answer to reflect fact that the settings.php factor is only required if you have civi tables and drupal tables in different DBs  
  > **username_4**: I don't think this is always the case. You only need to edit the settings.php file when a new custom field set is created, not for every new custom field. CivicRM only creates a new table for each custom field set, not for each custom field.  
  
  ---
  
  