Hide subpanel depend on roles

Hello all,
I want to hide some subpanel base on role.
Anyone know how can I achieve this?


I am not sure it works, but if you disable the entire module in the Role (“access” column) doesn’t it remove subpanels?

Also try disabling “List views” since subpanels are derived from List views.

Tell me if this works! Thanks

Thanks for reply.
I already tried this, but it’s not working.

I have solved this with custom code.
I have create custom file in custom\Extension\modules\Leads\Ext\Layoutdefs/custom_file.php
and add below code. After adding code perform a “Quick Repair and Rebuild”.
And it’s work for me.

global $mod_strings, $app_strings, $sugar_config;
$objACLRole = new ACLRole();
$roles = $objACLRole->getUserRoles($GLOBALS['current_user']->id);
if($roles[0] == "Call Center"){


1 Like

use javascript to hide subpanel :slight_smile:

1 Like

Hi pepemon2018,
Any problem if I write this in Layoutdefs?
I’m new in suitecrm.
Thanks :slight_smile:

just tested it with the current LTS-version. Created a group, added role+user, works exactly as you described (column access=disabled is sufficient).

Exception: for activities and history I’m unsure if the principle works.

Thanks @diligent

About the other discussion, doing it in Layoutdefs versus Javascript, I believe in this case the Layoutdefs is better:

  • it’s faster handling the request on the server, the subpanel query doesn’t run

-less bandwidth consumed, less page load time

  • no data will be sent to the front-end, so it’s more secure if you really don’t mean the data to be there

Thanks pgr :slight_smile:

you can create javascript tag in layoutdefs. (y)

1 Like

Thanks pepemon2018,
I’ll try js :slight_smile:

get Subpanel ID ! then use js :slight_smile:

1 Like

Why would you want to use Javascript for this case?

I gave several reasons above, saying why it’t not very adequate. it seems to me it’s also a much more convoluted form of achieving the intended purpose.

You can simply tell SuiteCRM not to produce the subpanel, by unsetting a value in a array. Why would you want to tell it to produce the subpanel anyway, send it to the client, but inject Javascript in it, so it can then be insecurely hidden?

1 Like