Last Updated on June 1, 2022 by Rakesh Gupta
Big Idea or Enduring Question:
- How can you automatically add account team members to case team?
How nice would it be if Salesforce auto added users (specified account team role) from Account Team to Case Team whenever a case gets created? Well, we can cajole Salesforce to do just that by leveraging Salesforce Flow!
A Case Team is a set of people that usually work together to solve Cases. A typical Case Team may include support agents, support managers, product managers, etc.
If system admin has set up case teams, then users can add people to the Case Team related list on the cases. When adding a team member, choose one of the predefined roles that the person plays on the case. Roles determine the level of access to a case, such as read-only or read and write access. In the following example, role Helper grants case record Read Only access to Nathan Gilmore.
One can add contacts to case teams, but they can only access cases when they are enabled as customer portal users assigned to case page layouts. Customer portal users can not update case teams or view case team roles. Let us see how to get started on working smarter by tackling a business use case.
Objectives:
After reading this article, the reader will be able to:
- Understand CaseTeamMember and CaseTeamMemberRole and how to use it.
- Create a Record-Triggered Flow to automatically add account team member to case team.
- Learn how to use a Decision element to find whether a Record variable – or a Record collection variable – contains a record.
- Find out how to use the Loop element to extract records from a record collection.
- And, last but not least, discover how to use the Create Records element to create multiple records (add users to case team) at once (Bulk Safe).
Business Use Case
Martin Jones is working as a System Administrator at Gurukul on Cloud (GoC). At GoC they use Case Team to work together to close a case faster. Martin has received a requirement from the upper management:
Whenever a High priority case is created for an account, and if the account has Account team members with Role Pre-Sales Consultant then, add those account team members to case team with read-only access to the case.
Assumption
The organization-wide default for Account and Case are set to private and all account team members do not have access to related cases.
Automation Champion Approach (I-do):
There are a few possible solutions for the above business scenario, but I’ll use After-save Record-Triggered Flow to solve the business requirement.
Before we proceed further, let us understand the characteristics of a CaseTeamMember object – It represents a case team member, who works with a team of other users to help resolve a case.
Field Name | Details |
MemberId | The ID of the user or contact who is a member on a case team. |
ParentId | The ID of the case with which the case team member is associated. |
TeamRoleId | The ID of the case team role with which the case team member is associated. |
Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.
Let’s begin building this automation process.
Guided Practice (We-do):
There are 2 steps to solve Martin’s business requirement using Record-triggered Flow. We must:
- Create a case team member role
- Salesforce flow
- Define flow properties for record-triggered flow
- Create a formula to determine whether the record is created or updated
- Add a decision element to check case priority and account lookup
- Add a get record element to find account team members with the role pre-sales consultant
- Add a decision element to check if account team members was found or not (from step 2.4)
- Add a get records element to find the case team role pre-sales consultant
- Add a decision element to check if case team role (pre-sales consultant) was found or not (from step 2.6)
- Add a loop element to retrieve records from the record collection variable (from step 2.4)
- Add an assignment element to add case team member to a record variable
- Add an assignment element to add record variable to a record collection variable
- Add a create records element to add account team members to case team
Step 1: Create a Case Team Member Role
First of all, we will create a Case Team Member Role for Pre-Sales Consultant, as shown in the following screenshot:
Step 2.1: Define Flow Properties
- Click Setup.
- In the Quick Find box, type Flows.
- Select Flows then click on the New Flow.
- Select the Record-Triggered Flow option, click on Create
- Object: Case
- Trigger Opportunity Flow When: A record is created or updated
- Set Entry Criteria
- Condition Requirements: None
- Optimize the Flow For Action and Related Records
- Click Done.
Step 2.2: Formula to Determine Whether the Case is Created or Updated
- Under Toolbox, select Manager, then click New Resource to determine whether the record is created or updated.
- Input the following information:
- Resource Type: Formula
- API Name: forB_IsNew
- Data Type: Boolean
- Formula: IsNew()
- Click Done.
Step 2.3: Using Decision Element to Check Case Priority and Account Lookup
- On Flow Designer, click on the + icon and select the Decision element.
- Enter a name in the Label field; the API Name will auto-populate.
- Under Outcome Details, enter theLabel theAPI Name will auto-populate.
- Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
- Row 1:
- Resource: {!$Record.Priority}
- Operator: Equals
- Value: High
- Click Add Condition
- Row 2:
- Resource: {!$Record.Account}
- Operator: Is Null
- Value: {!$GlobalConstant.False}
- Click Add Condition
- Row 3:
- Resource: {!forB_IsNew}
- Operator: Equals
- Value: {!$GlobalConstant.True}
- Row 1:
Step 2.4: Adding a Get Record Element to Find the Account Team Members with Role Pre-sales Consultant
To find all account team members with the role (Pre-Sales Consultant), we will use Get Records element.
- On Flow Designer, below the Created node, click on the +icon and select the Get Records element.
- Enter a name in the Label field; the API Name will auto-populate.
- Select the Account Team Member object from the dropdown list.
- Select All Conditions Are Met (AND).
- Set Filter Conditions
- Click Add Condition
- Row 1:
- Field: AccountId
- Operator: Equals
- Value: {!$Record.AccountId}
- Click Add Condition
- Row 2:
- Field: TeamMemberRole
- Operator: Equals
- Value: Pre-Sales Consultant
- How Many Records to Store:
- select All record
- How to Store Record Data:
- Choose the option to Automatically store all fields.
- Click Done.
Step 2.5: Using Decision Element to Check If Account Team Member was Found or Not
Now, will use the Decision element to check if the previous Get Records element returns account team member record or not.
- On Flow Designer, click on the +icon and select the Decision element.
- Enter a name in the Label field; the API Name will auto-populate.
- Under Outcome Details, enter the Label the API Name will auto-populate.
- Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
- Row 1:
- Resource: {!Get_Account_Team_Member}
- Operator: Is Null
- Value: {!$GlobalConstant.False}
- Row 1:
- When to Execute Outcome: If the condition requirements are met.
- Click Done.
Step 2.6: Adding a Get Record Element to Find Case Team Member Role Pre-sales Consultant
Now we will use the Get Records element to find CaseTeamRole for Case Team Member Role Pre-Sales Consultant.
- On Flow Designer, below the Yes node, click on the +icon and select the Get Records element.
- Enter a name in the Label field; the API Name will auto-populate.
- Select the Case Team Member Role object from the dropdown list.
- Select All Conditions Are Met (AND).
- Set Filter Conditions
- Row 1:
- Field: Name
- Operator: Equals
- Value: Pre-Sales Consultant
- Row 1:
- How Many Records to Store:
- select All record
- How to Store Record Data:
- Choose the option to Automatically store all fields.
- Click Done.
Step 2.7: Using Decision Element to Check If Account Team Member was Found or Not
Now, will use the Decision element to check if the previous Get Records element returns a contact record.
- On Flow Designer, click on the +icon and select the Decision element.
- Enter a name in the Label field; the API Name will auto-populate.
- Under Outcome Details, enter the Label the API Name will auto-populate.
- Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
- Row 1:
- Resource: {!Get_CaseTeamRole}
- Operator: Is Null
- Value: {!$GlobalConstant.False}
- Row 1:
- When to Execute Outcome: If the condition requirements are met.
- Click Done.
Step 2.8: Add a Loop Element to Retrieve Records from Record Collection Variable (from step 4)
- On Flow Designer, below the Role Found node, click on the +icon and select the Loop element.
- Enter a name in the Label field; the API Name will auto-populate.
- For Collection Variable select {!Get_Account_Team_Member}.
- For Specify Direction for Iterating Over Collection select the option First item to last item.
- Click Done.
Step 2.9: Adding an Assignment Element to Add Case Team Member to a Record Variable
- Create a Record Variable varR_CaseTeamMember type Case Team Member to add the case team member.
- On Flow Designer, click on the +icon and select the Assignment element.
- Enter a name in the Label field; the API Name will auto-populate.
- Set Variable Values
- Row 1:
- Field: {!varR_CaseTeamMember.ParentId}
- Operator: Equals
- Value: {!$Record.Id}
- Add Assignment
- Row 2:
- Field: {!varR_CaseTeamMember.TeamRoleId}
- Operator: Equals
- Value: {!Get_CaseTeamRole.Id}
- Add Assignment
- Row 3:
- Field: {!varR_CaseTeamMember.MemberId}
- Operator: Equals
- Value: {!Loop_Over_Account_Team.UserId}
- Row 1:
- Click Done.
Step 2.10: Adding an Assignment Element to Add the Record Variable to Record Collection Variable
- Create a Record Collection Variable varR_CaseTeamMembers type Case Team Member to store record variable (created in step 2.9) for the bulk process.
- On Flow Designer, click on the +icon and select the Assignment element.
- Enter a name in the Label field; the API Name will auto-populate.
- Set Variable Values
- Row 1:
- Field: {!varR_CaseTeamMembers}
- Operator: Add
- Value: {!varR_CaseTeamMember}
- Row 1:
- Click Done.
Step 2.11: Adding a Create Records Element to Add Account Team Member to Case Team
The final task is to insert data into the Case Team Member object. For this, we will use the Create Records element.
- On Flow Designer, click on the +icon and select the Create Records element.
- Enter a name in the Label field; the API Name will auto-populate.
- For How Many Records to Create select Multiple.
- Map Record Collection: {!varR_CaseTeamMembers}
- Click Done.
In the end, Martin’s Flow will look like the following screenshot:
Once everything looks good, perform the steps below:
- Click Save.
- Enter Flow Label the API Name will auto-populate.
- Click Show Advanced.
- API Version for Running the Flow: 55
- Interview Label: Add Case Team Members {!$Flow.CurrentDateTime}
- Click Save.
Almost there! Once everything looks good, click the Activate button.
Proof of Concept
Next time, when a high priority Case is created for an account by the user, the record-triggered flow we created will fire and add pre-sales consultants from account team, to the Case Team.
I hope you enjoyed, and learned, from the blog, how to add, members from an account team to the case team. Mastering these skills will enhance your productivity and propel you to try various permutations and combinations to incorporate automation in your day-to-day processes and procedures.
Formative Assessment:
I want to hear from you!
What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.
This is a helpful article for learning how to use flow + existing standard objects to open up sharing access, but why would you not just enable AccountTeams and set CaseAccessLevel = “Read”? My understanding is that AccountTeamMembers automatically get access to Cases associated with their Account. Why do we need to add them as Case Team Members too?
Excellent point! There are situations when the business only wants to give case access to account team members if necessary.
Hi Rakesh,
I can’t find the value in step 9(assignment element)
Row 2:
Field: {!varR_CaseTeamMember.TeamRoleId}
Operator: Equals
Value: {!Get_CaseTeamRole.Id}.
Where do I get this value from?
Thanks!
Check step 2.9.1
How can we add contacts for eg: contact roles to the Case Team?
Thanks for the Quick reply, But I am not able to find MemberId, TeamRoleId in that, Is the fields that you mentioned before Step1, need to be created customly in the system? Can you please guide me as per the updated flow version.
It’s CaseTeamMember record variable
Can you please tell the Full variable name in Step 7?
SovPreSalesConsultant – Record Variable to store CaseTeamMember
Hello Rakesh,
Thank you for this! I am stuck on step 7. I don’t see what to put in the variables of the three you noted (my Account Team role is called ClientServiceDirector). How are you populating these variables?
Can you provide a full screenshot of step 7? There is more detail in the Variable field that we can’t see. Thank you!
Full screenshot is already posted. Please let me know if you have any question or doubt.