2

We have a simple directory built with Views and a few exposed filters for searching. One of the (non-exposed) filters is intended to make sure all listed contacts are not marked as deceased. However, the filter does not have a negate option so instead of Is Deceased NOT TRUE we have to do Is Deceased FALSE. We may have even had to set the 'Is Deceased' field to 0 in the database directly, I can't recall. That part was working fine.

'Is deceased' filter in views

However, we also have a simple profile set up to allow editing of the contacts, adding a photo, and marking as deceased as necessary. What we've found is that when a contact is edited (to update the address or add a photo for example), the "Is Deceased" field is reset to NULL and this excludes them from the directory (because the field does not equal FALSE anymore).

What is a better way to handle this?

  • 1
    This seems like a general problem with views integration - civicrm boolean yes/no fields often need a more complex selection than True or False. – Alan Dixon Apr 7 '15 at 20:44
2

In the end, I removed the "Is Deceased" option from the profile we use to edit the contact's information and created a separate profile which contains only that field. It's a little clunky to present two edit links:

  • Edit contact information
  • Mark contact as deceased

...but it works for now. I would have tried it in a Webform (with Webform CiviCRM) but I don't think the image handling pushes back into CiviCRM.

1

Since the end goal is to display data in Views, can you use a small module to alter the views query, rather than customizing Civi? I haven't tried views_query_substitutions personally (I've usually hooked into views_query_alter), but I think this is a simple fix that could solve the problem:

function hook_views_query_substitutions($view) {
  // Example from views_views_query_substitutions().

  return array(
    "civicrm_contact.is_deceased = '0'" => "civicrm_contact.is_deceased = '0' OR civicrm_contact.is_deceased IS NULL",
  );
}
  • I gave it a quick try and it didn't take but I appreciate the idea. I will keep this in my back pocket for the future but can't devote too much time to this minor issue. – Laryn - CEDC.org Apr 8 '15 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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