I created the relationship between Users and Documents and the custom subpanel in Documents:
custom/Extension/modules/Documents/Ext/LayoutDefs/documents_employees_1_Documents
<?php
$layout_defs["Documents"]["subpanel_setup"]['document_employees'] = [
'order' => 100,
'module' => 'Employees',
'subpanel_name' => 'employees',
'get_subpanel_data' => 'function:getEmployeesForDocument',
'generate_select' => true,
'title_key' => 'LBL_DOCUMENT_EMPLOYEES',
'top_buttons' => [],
'function_parameters' => [
'import_function_file' => 'custom/modules/Documents/getEmployeesForDocument.php',
'document_id' => $this->_focus->id,
'return_as_array' => 'true'
]
];
custom/modules/Documents/getEmployeesForDocument.php
<?php
function getEmployeesForDocument($params) {
$args = func_get_args();
$documentId = $args[0]['document_id'];
return [
'select' => " SELECT users.*",
'from' => " FROM users",
'where' => " WHERE users.deleted = '0'",
'join' => " INNER JOIN users_documents_1_c ON users_documents_1_c.users_documents_1users_ida = users.id AND users_documents_1_c.deleted = '0'"
. " INNER JOIN documents ON documents.id = users_documents_1_c.users_documents_1documents_idb AND documents.deleted = '0' AND documents.id = '$documentId'",
'join_tables' => []
];
}
but i am getting the following exception when trying to open the subpanel:
PHP Fatal error: Uncaught Error: Call to a member function isCollection() on boolean in /home/www/data/SugarBean.php:639\nStack trace:\n#0 /home/www/include/ListView/ListView.php(1102): SugarBean::get_union_related_list(Object(Document), 'id', 'asc', '', '', -1, 10, '', false)\n
#1 /home/www/include/ListView/ListViewSubPanel.php(142): ListView->processUnionBeans(Object(Document), false, '_CELL')\n
#2 /home/www/include/SubPanel/SubPanel.php(220): ListViewSubPanel->process_dynamic_listview('Documents', Object(Document), false)\n
#3 /home/www/include/SubPanel/SubPanel.php(231): SubPanel->ProcessSubPanelListView('include/SubPane...', Array)\n
#4 /home/www/include/SubPanel/SubPanelViewer.php(95): SubPanel->display()\n
#5 /home/www/include/MVC/Controller/SugarController.php(936): require_once('/home/www/inclu...')\n
#6 /home/www/include/MVC/Controller/SugarController.php(402): SugarController->handleActionMaps()\n
#7 /home/www/include/MVC/Controller/SugarController.php(315): SugarController->process()\n
#8