SuiteCRM 7.13.4 - Subpanel filter button causes javascript error

Good evening,

I’ve managed to create a “Filter” button for Leads in Prospect Lists by using the following code:

$layout_defs["ProspectLists"]["subpanel_setup"]['leads']['top_buttons'] =
  array (
    0 => 
    array (
      'widget_class' => 'SubPanelTopButtonQuickCreate',
    ),
    1 => 
    array (
      'widget_class' => 'SubPanelTopSelectButton',
      'mode' => 'MultiSelect',
    ), 
    2 => 
    array (
      'widget_class' => 'SubPanelTopFilterButton',
    ), 

  );

  $layout_defs["ProspectLists"]["subpanel_setup"]['leads']['searchdefs'] =
array ( 'name' =>
        array (
            'name' => 'name',
            'default' => true,
            'width' => '10%',
        ),
        );

I’ve also tried variations of the code that use relationship names for the module name, as well as unsetting the original subpanel beforehand.

Whenever I press the Filter button, instead of displaying the search panel, I get a javascript error:

“Uncaught TypeError: document.getElementById(…) is null”

The line that gives the error is sugar_grp1.js:21:27 :

var tables = document.getElementById("list_subpanel_"+subpanel).getElementsByTagName("table");
    var module = get_module_name();

    var row = tables[0].insertRow(1);
    row.id = subpanel+'_search';
    row.className = "pagination";
    row.style.display = 'none';

I wasn’t able to find thse lines in the file in my cache folder as the debugger would suggest.
It seems like the function can’t find the element by id, even though I’ve checked that the “subpanel” variable is a string that does indeed contain the subpanel name and that such a “list_subpanel_”+subpanel div does exist and contains a table.
I’m quite at a loss, if anyone could help it would be greatly appreciated

The following code worked, although I’m sure I’ve tried it before…

unset($layout_defs["ProspectLists"]["subpanel_setup"]['leads']);
$layout_defs["ProspectLists"]["subpanel_setup"]['prospect_list_leads'] = array (
		'order' => 10,
		'sort_by' => 'name',
		'sort_order' => 'asc',
		'module' => 'Leads',
		'subpanel_name' => 'default',
		'get_subpanel_data' => 'leads',
		'title_key' => 'LBL_LEADS_SUBPANEL_TITLE',
		'top_buttons' => array(
			array('widget_class' => 'SubPanelTopButtonQuickCreate'),
			array('widget_class' => 'SubPanelTopSelectButton','mode'=>'MultiSelect'),
            		array('widget_class' => 'SubPanelTopFilterButton'),
		),
);
  $layout_defs["ProspectLists"]["subpanel_setup"]['prospect_list_leads']['searchdefs'] =
array ( 'name' =>
        array (
            'name' => 'name',
            'default' => true,
            'width' => '10%',
        ),
        );
1 Like