Hello,
The answer is tricky. But Role which will be applied like, user can see the records assigned to them, not the ones created by them!
So, the possible solution is override the list view query and get the records which are belongs to them and created by them, without applying any roles to users.
As it is Sugar module, we have to find a way to customize the way, to make the changes upgrade safe. So, you will need to follow the steps.
Copy and paste the controller.php from modules/Contacts to custom/modules/Contacts and add following code in the class ContactsController
PHP Code:
function action_listview()
{
require_once('custom/modules/Contacts/MyCustomListView.php');
$this->view_object_map['bean'] = $this->bean;
$this->view = 'list';
$GLOBALS['view'] = $this->view;
$this->bean = new MyCustomListView();
}
Now next step is to create a new file custom/modules/Contacts/MyCustomListView.php and following code there.
PHP Code:
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
// extending list view query THE UPGRADE SAFE WAY..........
class MyCustomListView extends Contact
{
function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false)
{
global $current_user;
$and = "";
if(!empty($where))
$and = " AND ";
// Adding Extra Condition to allow users to view records created by them.
$where .= " ".$and."(contacts.assigned_user_id = '".$current_user->id."' OR contacts.created_by='".$current_user->id."')";
return parent::create_new_list_query($order_by, $where, $filter, $params, $show_deleted, $join_type, $return_array, $parentbean, $singleSelect);
}
}
P.S. DONT put role List > Owner.
Bookmarks