function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AprilVAprilV 

Apex Case Trigger - Automatically assign Case Team members based on User who created case?

Is there a way to create an APEX case Trigger that will automatically assign case team members based on the user who created the case and/or based on a user in a relative lookup field?

 

If so, would anybody be able to offer me some sample code that could help me jump start my trigger attempt?

Janet GuoJanet Guo

There is. 

 

There is an object called CaseTeamMember (you can read about it's methods here, though the main methods you need to worry about are MemberId and ParentId). In your Case trigger, just create a new CaseTeamMember record for every Case record you find whose Case Owner (or lookup field) is a User.

 

Hope that helps!