How to implement Team-based views?

Dear community,

One of our customers is restructuring his sales organisation with slightly specific rules of engagement: one sales team may have access to records from another team, but not to all of the fields in these records. 

Example :

Account viewed by a member of Team A, owner of the record: 

  • Company name : ITS4U
  • Company address : 136...
  • Company status: Prospect
  • Company staff: 65

etc. 

Account viewed by a member of Team B: 

  • Company name : ITS4U
  • Company address : 136...
  • Company status: (Hidden)
  • Company staff: (hidden)

We're aware that the standard is role-based views, not team-based. But roles won't make the trick here. 

We could also alter the record view, but that would not prevent users from accessing the info via reports or, probably, the mobile application. 

Any idea on how to approach this without creating duplicate records or a second Account entity?

Cheers,

Damien

  • You can hid some fields based on a custom sugarLogic function isUserInTeamList.

    Save the attached script into custom/include/Expressions/Expression/Boolean/isUserInTeamListExpression.php

    Go to Admin - > Repair, and run the following actions:

    • Quick Repair and Rebuild
    • Rebuild Sugar Logic Functions (twice)
    • Rebuild JS Grouping Files
    • Clear Additional Cache

    Finally you need to implement a SetVisibility Dependency in order to make such fields visible only if current user is assigned to a specific set of teams.

    $dependencies['Accounts']['team_based_visibility'] = array(        'hooks' => array("edit"),        'triggerFields' => array(),        'onload' => true,        'actions' => array(            array(                'name' => 'SetVisibility',                'params' => array(                    'target' => 'status_c',                    'value' => 'isUserInTeamList(createList("Team A"))',                ),            ),        ),    );

    After saving such dependency you have to run the Repair actions:

    • Quick Repair and Rebuild
    • Clear Additional Cache

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hello.  I have a similar situation, however the provided resolution is 3 years old.  Has thre been any updates in SUGAR that would make this situation easier to handle?