How can I hide a field based on role from the Leads module in Community Edition?

ScenarioUser creates the lead; he should be able to input information to a field name "CUST_PERSONAL"; however, every time there after the field should be visible only to ROLE:Manager, OWNER and should be hidden from Role: DataEntry, FollowUP.

In CE you can use SecuritySuite (https://www.sugaroutfitters.com/addons/securitysuite) to create custom layouts for different groups of users. So you could create a group called DataEntry and add a custom layout for that group in Studio. Then show the field on the Edit View, but hide it on the Detail View.

The next problem is that it will always show on the Edit View whether it is the initial creation or a subsequent edit. I have an open feature request in SecuritySuite to separate the rights for Create and Edit. When that is implemented you can prevent Data Entry folks from editing data after entering it.

For now, you can add that custom logic in the view.edit.php. Create custom/include/MVC/View/views/view.edit.php and extend include/MVC/View/views/view.edit.php. Then check to see if this is an existing record and if the current user belongs to the Data Entry group. If yes, then redirect to the detail view. There are some other possibilities that you could do there as well such as display an error or hide the edit button altogether based on the same logic.

As a sensible business, if they will save more money buying something off the shelf versus paying for services they will almost always do that. Buying off the shelf is almost always cheaper as cost is spread out amongst many users. Plus you will have earned a client for life by showing that you are looking out for their best interest and not your own.

For hard coded solutions, Andre's usually always works. I'm guessing his example is looking up the current user's role and removing the field as appropriate.

If you can share the solution or where you are getting stuck here it would help others down the road as the old forum is in the process of being turned off.

Hi,Yes its possibleGrab the user role using the followingCode:$acl_role_obj = new ACLRole();$user_roles = $acl_role_obj->getUserRoles($current_user->id);$user_roles will have the list of rolesHide the panel display using javascript codeCode:document.getElementById('LBL_SOMETHING').style.display="none";LBL_SOMETHING would be the panels system nameWrite all this code in custom/modules/YourModule/views/view.edit.php (or/and) view.detail.php Hope it helpsCheers,Ishaan

The problem is accounts and other modules, are way too different from Leads. So I understand that for hiding custom field from leads module I have to change:

custom/include/MVC/View/views/view.detail.php

I am trying to adopt this:

1. Edit the editviewdefs.php and detailviewdefs.php and convert the panels name to upper case;2. Create a single metadata file into custom/modules/Leads/metadata/toggle_panel_fieldsdefs.php with the content:PHP Code:

<?php $toggle_panel_fieldsdefs = array(

'OS_OWN' => array(

'LBL_CC_INFO' => 1,

// 'PANEL2' => 1,

// 'PANEL3' => 0, ),

), 'DE_SALES' => array(

'LBL_CC_INFO' => 0,

// 'PANEL2' => 1,

// 'PANEL3' => 0, ), ); ), ); ?>

3. Modify the role name and panel name to fit your needs; //changed accounts to lead and rest above;4. Create the file custom/modules/Leads/views/view.detail.php with this content:PHP Code:

I believe that method of unsetting the defs only works if you have developerMode turned on or if you bypass the cache somehow. If you don't then it will retrieve what is already in cache/modules/Leads/DetailView.tpl which means that your changes will not show.

You can output javascript and remove the element from the DOM after calling parent::display in view.detail.php. However, this is a client-side hack and isn't completely fool proof. Meaning that if someone in Data Entry disabled javascript or watched the server response they could easily access that field that they shouldn't have access to.

An alternative is to force the detail view to always rebuild the detail view instead of using the cached version. I don't have the code on hand, but there should be examples in the old forums.

1. Edit the editviewdefs.php [change constructor to ev] and detailviewdefs.php and convert the panels name to upper case;2. Create a single metadata file into custom/modules/Leads/metadata/toggle_panel_fieldsdefs.php with the content:

PHP Code:

<?php $toggle_panel_fieldsdefs = array(

'OS_OWN' => array(

'LBL_CC_INFO' => 1,

// 'PANEL2' => 1,

// 'PANEL3' => 0, ),

), 'DE_SALES' => array(

'LBL_CC_INFO' => 0,

// 'PANEL2' => 1,

// 'PANEL3' => 0, ), ); ), ); ?>

3. Modify the role name and panel name to fit your needs; //changed accounts to lead and rest above;4. Create the file custom/modules/Leads/views/view.detail.php with this content:PHP Code: