Dynamically filter Reseller Contacts by Reseller Account in Accounts module?

I’m running into issues trying to get a filter to work for a couple of Relate fields. I'm pretty new at this so hopefully it's something really basic that I've missed.

I have added two new Relate type fields (Reseller Account and Reseller Contact) on the Accounts module so that I can show the Reseller account and the Reseller contact that the Account does business with:

The Reseller Contact should be filtered by the Reseller Account so when the “Search and Select” is run, it should pre-filter the list of contacts for the selected Reseller Account.

The problem is that when I click on the “Search and Select” to search for the Reseller Contact, it shows the selected Reseller Account as the filter parameter, but it says that there is no data available:

It I manually type in that same Reseller account name and re- run the search, the list on contacts are correctly filtered:


I built the logic based on several examples, including:  https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/1319/dynamically-filter-contacts-by-account-in-quotes-module , so I’m wondering what I may have missed?


Here’s my code:

Two new fields:

reseller_c (Relate field, Accounts module)

resellercnt_c (Relate field, Contacts module).





$viewdefs['Contacts']['base']['filter']['basic']['filters'][] = array(

    'id' => 'filterContactsByAccountId',


    'filter_definition' => array(


            'account_id' => ''  



    'editable' => true,

    'is_template' => true,




           10 =>

              array (

                'readonly' => false,

                'name' => 'resellercnt_c',

                'studio' => 'visible',

                'label' => 'LBL_RESELLERCNT',

                'initial_filter' => 'filterContactsByAccountId',

                'initial_filter_label' => 'LBL_ACCOUNT_ID_FORCONTACT',








    extendsFrom: 'RelateField',

    initialize: function (options) {

        this._super('initialize', [options]);


    //Filter contacts to the Reseller Company's list of contacts

    getFilterOptions: function (force) {

        if (this._filterOptions && !force) {

            return this._filterOptions;


        if (this.getSearchModule() == 'Contacts' && this.def.name=='resellercnt_c') {

            this._filterOptions = new app.utils.FilterOptions()


                    'initial_filter': 'filterContactsByAccountId',

                    'initial_filter_label': 'LBL_ACCOUNT_ID_FORCONTACT',

                    'filter_populate': {

                        'account_id': this.model.get('reseller_c'),


                    'filter_relate': {

                        'account_id': this.model.get('reseller_c'),





        } else {

            this._filterOptions = new app.utils.FilterOptions()


                .setInitialFilter(this.def.initial_filter || '$relate')




        return this._filterOptions;






 $mod_strings['LBL_ACCOUNT_ID_FORCONTACT'] = 'Contacts for Reseller';





 // created: 2022-06-15 23:05:12

$dictionary['Account']['fields']['resellercnt_c']['labelValue']='Reseller Contact';




$dictionary['Account']['fields']['resellercnt_c']['filter_definition'] = [


        'account_id' => '#reseller_c'