In Suitecrm have a subpanel and when clicking 'Select' I want it to show only a specific set of records.
I have a subpanel definition file that looks like this and tried all possible variations in the section "initial_filter" but when the pop-up comes up it shows all of the records
$layout_defs["un_inventory"]["subpanel_setup"]['un_inventory_leads_1'] = array (
'order' => 0,
'module' => 'Leads',
'subpanel_name' => 'default',
'sort_order' => 'asc',
'sort_by' => 'id',
'title_key' => 'LBL_UN_INVENTORY_LEADS_1_FROM_LEADS_TITLE',
//'get_subpanel_data' => 'un_inventory_leads_1',
'get_subpanel_data' => 'function:get_parent_leads',
'function_parameters' =>
array('import_function_file' => 'custom/modules/Leads/func/get_parent_leads_file.php',),
'top_buttons' =>
array (
0 =>
array (
'widget_class' => 'SubPanelTopButtonQuickCreate',
),
1 =>
array (
//'widget_class' => 'SubPanelTopSelectButton',
'widget_class' => 'SubPanelTopSelectButtonParentProjectLeads',
'mode' => 'MultiSelect',
// 'initial_filter_fields' => "&first_name_advanced=hello",
// 'initial_filter' => array('parent_project_id_c_advanced' => array('83b30b20-83a6-8099-b3b9-5d4a491888e6')),
// 'initial_filter' => array('parent_project_id_c_advanced' => '83b30b20-83a6-8099-b3b9-5d4a491888e6'),
// 'initial_filter' => array('account_type_advanced' => array('Student')),
// 'initial_filter' => '&parent_project_id_c=83b30b20-83a6-8099-b3b9-5d4a491888e6',
),
),
);
There are many example of how this is done for 'relate' fields in editview, but not so much for subpanel's such as above, I'm pretty sure many would find this valuable.
Solution would probably be applicable to sugarcrm CE also
Solution is to override the default TopButtonSelect class and hardcode the $initial_filter variable.
So if we hardcode the value like so
$initial_filter.='&parent_project_id_c_advanced='.urlencode("83b30b20-83a6-8099-b3b9-5d4a491888e6");
It will only show records which have the parent_project_id_c field with the value 83b30b20-83a6-8099-b3b9-5d4a491888e6
Hope this helps
Source: http://qc-digital.com/filter-values-shown-when-we-click-on-select-button-inside-a-subpanel/