Filter Pop-up based on relationship

Anyone able to get this working? I tried what suggested in sugarcrm filter on relative field - Dev Answers & Best Practices - DevClub - SugarClub so far not working. Here is the code I am adding to custom/Extension/modules/RTPOL_OLP/Ext/Vardefs/sugarfield_contacts_rtpol_olp_1contacts_ida.php

$dictionary['RTPOL_OLP']['fields']['contacts_rtpol_olp_1contacts_ida']['filter_definition'] = [
  [
    'account_id' => '#accounts_rtpol_olp_1accounts_ida'
  ]
];

I am trying to filter Contacts based on Account, but getting this working will lead to other filters.

Parents
  • You have to create a filter in Contacts module in custom/Extension/modules/Contacts/Ext/clients/base/filters/basic

    $viewdefs['Contacts']['base']['filter']['basic']['filters'][] = array(
        'id' => 'filterContactsByAccountId',
        'name' => 'LBL_FILTER_CONTACTS_BY_ACCOUNT_ID',
        'filter_definition' => array(       
            array(
                'account_id' => ''
            )
        ),
        'editable' => true,
        'is_template' => true,
    );

    And then in record.php of module RTPOL_OLP in the field Contact you call the initial filter:

    array (
        'name' => 'intermediary_contact_name',
        'label' => 'LBL_INTERMEDIARY_CONTACT_NAME',
    	  //the name of the filter template
    	'initial_filter' => 'filterContactsByAccountId',
    
    	//the display label for users
    	'initial_filter_label' => 'LBL_FILTER_CONTACTS_BY_ACCOUNT_ID',
    
    	//the dynamic filters to pass to the templates filter definition
    	//please note the index of the array will be for the field the data is being pulled from
    	'filter_relate' => array(
    		'intermediary_account_id' => 'account_id'
    	),
      ),

    I got this from a previous post but I didn't kept the link....

    I hope this help....

  • I tried but this is not working. I created the filter exact as you have shown, then added the reference in the record.php like so

     array (
                    'name' => 'contacts_rtpol_olp_1_name',
                    'label' => 'LBL_CONTACTS_RTPOL_OLP_1_NAME_FIELD_TITLE',
                    //the name of the filter template
                    'initial_filter' => 'filterContactsByAccountId',
    
                    //the display label for users
                    'initial_filter_label' => 'LBL_FILTER_CONTACTS_BY_ACCOUNT_ID',
    
                    //the dynamic filters to pass to the templates filter definition
                    //please note the index of the array will be for the field the data is being pulled from
                    'filter_relate' => array(
                      'accounts_rtpol_olp_1accounts_ida' => 'account_id'
                    ),
                  ),
     

    I must still be missing something.

    Also, here is the link you are looking for Sugar Developer Guide 13.1 - Sugar Support (sugarcrm.com).

  • Show the code of the relation between module  RTPOL_OLP and the module Accounts.

Reply Children