Creating custom subpanel on Users module

Hi all,

I am trying to create a subpanel on the Users modules for any modules based on the created_by field on that module matching up with the id field on User, and am heavily basing it on examples in the following forum string from pgr:

is this possible, or is Users some kind of special module? I am getting a permanent loading circle when trying to open the subpanel, and can create subpanels fine using that example above on other modules.

I don’t see why it wouldn’t work for Users module.

It’s better if you include your full code, file paths and names, and the exact error you’re seeing. Maybe it’s just some minor detail that is wrong.

thanks pgr, here’s my code:



$layout_defs["Users"]["subpanel_setup"]['contacts'] = array(
    'order' => 80,
    'module' => 'Users',
    'sort_order' => 'asc',
    'sort_by' => 'first_name, last_name',
    'subpanel_name' => 'default',
    'get_subpanel_data' => 'function:getRelatedContactsQueryData',
    'function_parameters' => array(
        'import_function_file' => 'custom/modules/Users/GetUsersSubpanelData.php',
        'link' => 'contacts'
    'add_subpanel_data' => 'contact_id',
    'title_key' => 'LBL_CONTACTS_SUBPANEL_TITLE',


require_once 'custom/modules/Users/BuildContactsSubpanelQueryService.php';

function getRelatedContactsQueryData($param){
$service = new BuildContactsSubpanelQueryService();
return $service->BuildQuery($param);


class BuildContactsSubpanelQueryService

public function __construct(){}

public function buildQuery($param){
    global $app;
    $controller = $app->controller;
    $bean = $controller->bean;
    $query = "SELECT * FROM contacts WHERE contacts.created_by = '$bean->id'";
    return $query;

with title created by


on this fix I get a good looking subpanel header on the page but when you click it to drop it down its the loading circle(s) permanently, any advice? thanks again for your time

Look for errors both on the suitecrm.log and the php_errors.log

I’ve got MySQL error 1064: you have an error in your SQL syntax;
but I tried to mirror your syntax on that old example as strictly as possible, given that these are all default fields do you see anything glaringly wrong with my syntax in that query by chance?

SQL errors are usually more explicit than that, they tell you exactly what is wrong…

Try printing your $query variable to check if the quotes and variable substitution are working as intended.