We are trying to achieve a hierarchical approach to some of our case types by using case tags.

It works great on the back-end, but if I try to filter a view by the case tag, I get no results.

In the View UI, I add a filter of CiviCRM tags, see the case tags in the list, but if I select any of them, I get no results.

I've tried with tags attached to contacts, cases, attachments and activities. The only one that appears to work is when the tag is attached to a contact.

Since Smart Groups don't appear to function correctly in Views either, this functionality would be very useful.

Tables look good, view appears to be set up correctly. Tags is available as a field and I can see the correct Case Tags in the list of available tags.

I brought this issue up before, but have no resolution yet.

Here is a link to the old issue: Case Tags in View

  • I suspect this is new code required for the civi-views module.
    – petednz - fuzion
    Commented Jun 15, 2015 at 8:04
  • Have you tried the relationship option in the views module? In your view you can define relationship between entities. In your case you probably need Tag, TagEntity and Case. Commented Jun 15, 2015 at 11:18
  • Can't find Tag and TagEntity relationships in Views UI to add them. I'll poke around some more.
    – pmoz
    Commented Jun 15, 2015 at 11:48
  • Jaap's comment made me wonder what civi component your view is based on? Case, Activity, Contact?
    – petednz - fuzion
    Commented Jun 15, 2015 at 20:09
  • I've tried cases and contacts. I got the activity tag to work by creating an activity view, but not the case or attachment tags. But no matter which component the view is built on, I can't see Tag or EntitiyTag in the relationship UI.
    – pmoz
    Commented Jun 15, 2015 at 20:49

1 Answer 1


On a development server, I edited sites/all/modules/civicrm/drupal/modules/views/components/civicrm.core.inc.

In the Tag section, I added:

$data['civicrm_tag']['table']['join']['civicrm_case'] = array(
    'left_table' => 'civicrm_entity_tag',
    'left_field' => 'tag_id',
    'field' => 'id',


 $data['civicrm_entity_tag']['table']['join']['civicrm_case'] = array(
    // Directly links to tag table
    'left_field' => 'id',
    'field' => 'entity_id',
    'extra' => array(
        'field' => 'entity_table',
        'value' => 'civicrm_case',
        'numeric' => FALSE,

After that, I was able to filter by case tags.

Would this have any unforeseen ramifications? Does this cover all of my bases?

Would this be best put into a separate custom module?

  • If this does prove to add the required without creating other problems then best to provide as a patch to JIRA I think
    – petednz - fuzion
    Commented Jun 16, 2015 at 20:26

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.