Skip to content

Instantly share code, notes, and snippets.

@dmulvi
Created June 1, 2015 16:31
Show Gist options
  • Save dmulvi/da373282d3054a2523dd to your computer and use it in GitHub Desktop.
Save dmulvi/da373282d3054a2523dd to your computer and use it in GitHub Desktop.
Pre-filter Contacts by Account on Cases
<?php
// file location: /custom/Extension/modules/Contacts/Ext/clients/base/filters/basic/filterContactsFromRelatedAccounts.php
$viewdefs['Contacts']['base']['filter']['basic']['filters'][] = array(
'id' => 'filterContactsFromRelatedAccount',
'name' => 'Contacts of Related Account',
'filter_definition' => array(
array(
'account_id' => ''
)
),
'editable' => true,
'is_template' => true,
);
<?php
// file location: /custom/modules/Cases/clients/base/views/record/record.php
$viewdefs['Cases']['base']['view']['record'] = array (
'buttons' =>
array(
// button stuff here
),
'panels' =>
array(
// find the panel that has the contact relationship field you want to apply the filter to
0 =>
array (
'name' => 'panel_header',
'header' => true,
'fields' =>
// lots of other fields here, removed for brevity
array (
20 =>
// this is where the magic happens, basically telling the contact field to use
// the pre-filter we defined in Contacts module
array (
'name' => 'contacts_cases_1_name',
'label' => 'LBL_CONTACTS_CASES_1_FROM_CONTACTS_TITLE',
'initial_filter' => 'filterContactsFromRelatedAccount',
'initial_filter_label' => 'Contacts of Related Account',
'filter_relate' =>
array (
'account_id' => 'account_id',
),
),
// end the magic
),
),
),
'templateMeta' =>
array (
'useTabs' => false,
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment