Create default Contact filter for specific Account in custom module

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:

<?php

$viewdefs['Contacts']['base']['filter']['basic']['filters'][] = array(
    'id' => 'filterContactTemplate',
    'name' => 'LBL_FILTER_CONTACT_TEMPLATE',
    'filter_definition' => array(
        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',
            )
       ),
Parents Reply Children
  • When I try to install the file through Module Loader I cannot get past the package scan. I get the error:

    File Issues

    clients/base/api/CustomFilterApi.php
    Invalid usage of a function array_walk()
    Invalid usage of a function is_callable()

    I did not alter any of these commands in the code. I assume this is because you cannot make these calls in a custom file in the custom directory. Is there another way to make these changes for only the small bit that needs to be altered without copying over the entire FilterApi.php file? Because this is an on-demand instance I cannot disable the package scan to force the file to install.
  • Hi Tony Lokey,

    My apologies. I am not aware of a way to extend that file.

    You are correct that you will need a different solution for Sugar's cloud services.

    According to the Sugar Cloud Policy Guide, SugarCRM will not host the workaround I mentioned above, stating:

    "You should note that Sugar's cloud service does not allow the overwriting of Sugar core files with customized versions."