What are Case Teams?
A case team is a group of people that work together to solve cases. They provide a clear way to document the roles of multiple users in the management of a single case. They also extend record access to team members (which can include community users). For example, a case team can include support agents, support managers, and product managers.Configuring Case Teams
1. Define Team Roles Mo
Navigate to Setup -> Customize -> Cases -> Case Teams -> Case Team Roles
2. Modification on Case Page Layout
Navigate to Setup -> Customize -> Cases -> Page Layouts
Add the Case Team related list to each case page layout:
Predefined Case Teams
There is one more great feature provided by salesforce through which we can predefine case teams so that support agents can quickly add people who they frequently work with cases.
Navigate to Setup -> Customize -> Cases -> Case Teams -> Predefined Case Teams
Above we have seen how we can set up or manage Case Teams using point and click. Now let us see if the developer has to manage Case Teams through code so what all objects will be included.
Below are the objects which are included to manage the Case Teams functionality
To manage Predefined Case Team functionality CaseTeamTemplate, CaseTeamTemplateMember, and CaseTeamTemplateRecord objects are used.
CaseTeamTemplateRecord object works as a linking object between Case and CaseTeamTemplate objects.
Below is the sample code which helps to understand the relationship for Predefined Case Team functionality:
CaseTeamTemplate cttObj = new CaseTeamTemplate(Description = 'Group of agents to which case can be assigned.',Name = 'Support Agent');insert cttObj;
List<CaseTeamTemplateMember> cttmList = new List<CaseTeamTemplateMember>(); cttmList.add(new CaseTeamTemplateMember(MemberId = '005XXXXXXXXXXXX',TeamRoleId = '0B7XXXXXXXXXXXX', TeamTemplateId = cttObj.Id)); cttmList.add(new CaseTeamTemplateMember(MemberId = '005YYYYYYYYYYYY',TeamRoleId = '0B7YYYYYYYYYYYY', TeamTemplateId = cttObj.Id)); insert cttmList;//Run below lines after executing above lines because it gives MIXED_DML error when executed simultaneously//CaseTeamTemplateRecord is a juntion object between Case and CaseTeamTemplateList<CaseTeamTemplate> cttlist = [Select Id from CaseTeamTemplate where Name = 'Admin'];CaseTeamTemplateRecord cttrObj = new CaseTeamTemplateRecord(ParentId = '500ZZZZZZZZZZZZ', TeamTemplateId = cttlist[0].Id); insert cttrObj;