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

  • 1
    Have you updated your settings.php file since creating the new custom fields?
    – pmoz
    Jun 16, 2015 at 19:00
  • 1
    The settings.php factor is only required if you have civi tables and drupal tables in different DBs
    – petednz - fuzion
    Jun 16, 2015 at 20:19
  • 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.
    – spinsheet
    Jun 17, 2015 at 12:01
  • 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!
    – spinsheet
    Jun 17, 2015 at 12:30

1 Answer 1


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/

  • 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
    – petednz - fuzion
    Jul 10, 2015 at 2:20
  • 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.
    – Graham
    Nov 10, 2016 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.