AnsweredAssumed Answered

Create default Contact filter for specific Account in custom module

Question asked by Tony Lokey on Mar 12, 2018
Latest reply on Mar 13, 2018 by Patrick McQueen

I am trying to create a default filter for the related Contact record using the Account field related to the custom module. The Accounts and Contacts module have one-to-many relationships with my custom module. I have created the filter and added the changes to record.php for the custom module. However, when I choose the "Search and Select..." option from the Contact field the search window shows the filter and selects the "Account Name" for the search parameter and enters the name in the "Select Account" (search) box. The problem is that no matter what I choose for the operator ($starts, $contains, $in, $equals, etc.) the "Select" box is either blank or correctly shows "is any of" but gives me an error saying "Error: $in requires an array". The error always refers to "$in" even if the operator is not "$in". Anybody have any ideas what is causing the problem or what operator or parameters I should be using? Am I doing this all wrong? It seems like this is really close to doing what I need.

My filter looks like this:


$viewdefs['Contacts']['base']['filter']['basic']['filters'][] = array(
    'id' => 'filterContactTemplate',
    'filter_definition' => array(
            'account_name' => array(
                '$contains' => array(),
    'editable' => true,
    'is_template' => true,

The code in the custom module looks like this (account_filter_c is the Account name):

array (
      'name' => 'contacts_sr_service_reports_1_name',
      'initial_filter' => 'filterContactTemplate',
      'initial_filter_label' => 'LBL_FILTER_CONTACT_TEMPLATE',
          'filter_relate' => array(
          'account_filter_c' => 'account_name',