Last Updated on June 2, 2022 by Rakesh Gupta
Big Idea or Enduring Question:
- How can you automatically add a specific user to the new user’s default account team?
How nice it would be if Salesforce auto adds a user (specified user) to Default Account Team for each new user? Well, we can cajole Salesforce to do just that by leveraging Salesforce Flow!
An Account Team is a set of users that usually work together on an Account. A typical Account Team may include an Account Manager, Sales representative, Legal advisor, etc. In Salesforce, a user can define Account Team in two places as follows:
1. Define Default Account Team on user’s record.
If a user selects Automatically add my default account team to accounts that I create or accounts that are transferred to me checkbox then Salesforce will auto add Default Account team members to a new account.
2. Manually add the members to Account Team for each new account record.
Once a new user is successfully logged into Salesforce, the next task is for them to set up preferences for email and add members to Default Account and Opportunity Teams. Although organizations have onboarding training for new users, at times, a user may miss setting up critical settings. If so then, why not leverage Process Builder and/or Visual Workflow to avoid such mishaps? 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 UserAccountTeamMember and how to use it.
- Create a Record-Triggered Flow to automatically add members to the user’s default account team.
- Learn how to use a Decision element to find whether a Record variable – or a Record collection variable – contains a record.
- And, last but not least, discover how to use the Create Records element to create a record
Business Use Case
Martin Jones is working as a System Administrator at Gurukul on Cloud (GoC). At GoC they use the Account Team to easily track collaboration on Accounts. They have a Legal Advisor (Sarika Gupta) who helps them on the legal side for all deals. Martin has received two requirements from the higher management:
- Add Sarika Gupta, a Legal Advisor, to the Default Account Team, on the new user’s record. So that, when an account owner clicks on Add Default Team (Using button available on the Account Team related list) or selects Automatically add my default account team to accounts that I create or accounts that are transferred to me checkbox, it will add Default Account Team members to Account Team on an account record.
- Add Legal Advisors (all users with profile legal advisor) to new accounts (This would work in cases where a user does not select Automatically add my default account team to accounts that I create or accounts that are transferred to me checkbox). Blog 146
They wanted to grant the following access to the legal Advisor as stated below:
- Account:- Read
- Contact :- Read
- Case:- Private
- Opportunity:- Read
Automation Champion Approach (I-do):
I am going to discuss the first requirement in this blog post. For the second requirement, please check out this article Auto Add Members to Account Team.
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 UserAccountTeamMember object – It represents a User on the default account team of another User.
Field Name | Details |
OwnerId | The ID of the User who owns the default account team. |
TeamMemberRole | The role that the team member has on opportunities for which the user has added his or her default account team. |
UserId | the ID of the User who is a member of the default account team. |
AccountAccessLevel / CaseAccessLevel/
ContactAccessLevel / OpportunityAccessLevel |
Level of access that the User has to the Account, Case, Contact, and Opportunity. The possible values are:
|
Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understanding it.
Let’s begin building this automation process.
Guided Practice (We-do):
There are 6 steps to solve Martin’s business requirement using Record-triggered Flow. We must:
- 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 if the user is created and active
- Add a get record element to find the legal advisor (Sarika Gupta) details
- Add a decision element to check if a legal advisor was found or not (from step 4)
- Add a create records element to add a legal advisor (Sarika Gupta) to the new user’s default account team
Step 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: User
- 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: Formula to Determine Whether the User 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 3: Using Decision Element to Check If the User is Created and Active
- 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: {!$Record.IsActive}
- Operator: Equals
- Value: {!$GlobalConstant.True}
- Click Add Condition
- Row 2:
- Resource: {!forB_IsNew}
- Operator: Equals
- Value: {!$GlobalConstant.True}
- Row 1:
Step 4: Adding a Get Record Element to Find Legal Advisor User (Sarika Gupta)
To find Legal Advisor profile details, we will use the 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 User object from the dropdown list.
- Select All Conditions Are Met (AND).
- Set Filter Conditions
- Row 1:
- Field: Name
- Operator: Equals
- Value: Sarika Gupta
- Click Add Condition
- Row 2:
- Field: IsActive
- Operator: Equals
- Value: {!$GlobalConstant.True}
- Row 1:
- How Many Records to Store:
- select Only the first record
- How to Store Record Data:
- Choose the option to Automatically store all fields.
- Click Done.
Step 5: Using Decision Element to Check If Legal Advisor was Found or Not (from step 4)
Now, will use the Decision element to check if the previous Get Records element returns a user 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_Legal_Advisor}
- Operator: Is Null
- Value: {!$GlobalConstant.False}
- Row 1:
- When to Execute Outcome: If the condition requirements are met.
- Click Done.
Step 6: Add Create Records Element to Add a member to New User’s Default Account Team
The final step is to add a member to Default Account Team for new users. For this, we will use Create Records element.
- On Flow Designer, below the Yes node, click on the +icon and select the Create Records element.
- Enter a name in the Label field; the API Name will auto-populate.
- Input the following information:
- How Many Records to Create: One
- How to Set the Record Fields: Use separate resources, and literal values
- Object: UserAccountTeamMember
- Set Field Values for the User Account Team Member
- Row 1:
- Field: OwnerId
- Value: {!$Record.Id}
- Click Add Field
- Row 2:
- Field: UserId
- Value: {!Get_Legal_Advisor.Id}
- Click Add Field
- Row 3:
- Field: TeamMemberRole
- Value: Legal Advisor
- Click Add Field
- Row 4:
- Field: AccountAccessLevel
- Value: Read
- Click Add Field
- Row 5:
- Field: ContactAccessLevel
- Value: Read
- Click Add Field
- Row 6:
- Field: CaseAccessLevel
- Value: Private
- Click Add Field
- Row 7:
- Field: OpportunityAccessLevel
- Value: Read
- 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: Auto Add Member to New User’s Default Account Team {!$Flow.CurrentDateTime}
- Click Save.
Almost there! Once everything looks good, click the Activate button.
Proof of Concept
Next time, when a User is created by the system administrator, the record-triggered flow we created will fire and add Sarika Gupta, to the User’s Default Account Team.
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.
Thank You.. and 1 question, How can I tick the BOX?
There are 2 checkboxes when adding a Default Account Team Member. I would like to select these checkboxes as True or surface the field in the screen flow.
1. Automatically add my default account team to accounts that I create or accounts that are transferred to me
2. Update account teams with these members
Great article that gives a better idea of what we can do with Flow.
Great! Thanks for the feedback