1

I have referred the following resources.

But I am not able to find how can we assign users to case teams dynamically. I am not able to find any link between the two. Please suggest.

1
  • What do you mean by dynamically? what's your requirement and what have you tried?
    – PepeFloyd
    Aug 1, 2014 at 8:48

1 Answer 1

1

I would do it this way:

public static void shareCase(Case theCase, User caseTeamMember, String teamRole)
{
     /* get the Id for the case team role */

     CaseTeamRole role = [select Id from CaseTeamRole where Name = :teamRole limit 1];

     /* include the user on the case team */

     insert new CaseTeamMember(ParentId = theCase.Id, MemberId = caseTeamMember.Id, TeamRoleId = role.Id);
}
2
  • 3
    JannieT it's highly preferable to not just link to answers elsewhere. Could you include the core content of the answer given there ? Jul 31, 2014 at 14:55
  • This isn't really bulk safe at all. Also in my experience inserting a TeamMember record without first ensuring a Share record is present will result in DmlException.
    – Adrian Larson
    Feb 22, 2016 at 14:51

Not the answer you're looking for? Browse other questions tagged .