Last Updated on December 5, 2020 by Rakesh Gupta
Once an Account Manager creates a new account, the Manager can add, a team member, or multiple team members, to an Account Team. This blog is a sequel to my previous blog – Getting Started with Process Builder – Part 80 (Auto Add Member to New User’s Default Account Team).
As you may recall from my previous blog, an Account Team is a set of users that usually work together on an Account. A typical Account Team may include Account Manager, Sales representative, Legal advisor, etc. In the previous blog, I discussed how to automatically add a member to new user’s default account team. In this blog, I will go one step further and discuss requirement #2 – how to add multiple team members to an account team.
In Salesforce, a user can define Account Team in two places:
- Define Default Account Team on user’s record
- Manually add the members to Account Team for each new account record
Furthermore, one user can be associated with multiple Account Teams, and an account team can have multiple users. Yes! You are right! A Junction object is needed if one user is to be associated with multiple account teams and an account team is associated with multiple users. Lo and behold, there is such a junction object that connects one team member to multiple account teams and associates multiple account teams with a user. The object is called AccountTeamMember! In other words, the AccountTeamMember is a junction object between Account and User, as shown in the following screenshot:
Business Use case
Martin Jones is working as a System Administrator at Gurukul on Cloud (GoC). At GoC they use Account Team to easily track collaboration on Accounts. GoC has a team of Legal Advisors that helps on the legal side of all deals. Martin has received a new requirement from the higher management:
- Automatically add Legal Advisors (all legal advisors) to new accounts if the account Type =”Customer – Direct” and grant them the following access as stated below:
- Account:- Read
- Contact :- Read
- Case:- Private
- Opportunity:- Read
Solution for the above business requirement
There are a few possible solutions for the above business scenario, but we’ll use Flow and Process Builder to solve the above business requirement. Before trying to understand the technical aspect of the solution, let us spend some time to understand the general flow at a high level. Please spend few minutes to go through the following flow diagram and understand it.
Before we proceed further, let us understand the characteristics of an AccountTeamMember object – It represents a User on the default account team of another User.
Field Name | Details |
UserId | ID of the User who is a member of this account team |
AccountId | ID of the Account to which this user is a team member |
TeamMemberRole | Role associated with this team member |
AccountAccessLevel/CaseAccessLevel/
ContactAccessLevel/OpportunityAccessLevel |
Set Access level for account, case, contact and opportunity objects. |
- First of all, we will create a new Custom Label to store the Legal Advisor’s profile ID.
- To create a custom label click on Setup (Gear Icon) | Setup | User Interface | Custom Labels
- The next step is to create a Flow, by clicking on Setup (Gear Icon) | Setup | Process Automation | Flows
- Click on New Flow, it will open flow canvas for you.
- To access custom label in flow, you must create a formula. Create one formula For_LegalAdvisorProfileID, as shown in the following screenshot:
- Also create few variables in the Flow, as shown in the following table:
Name Variable type Object type Input/Output type VarTAccountId Text Not applicable Input and Output SocLegalAdvisors SObject Collection Variable User Input and Output SovLegalAdvisor SObject Variable User Input and Output SovAccountTeamMember SObject Variable AccountTeamMember Input and Output SocAccountTeamMembers SObject Collection Variable AccountTeamMember Input and Output - To find all users with the profile (Legal Advisor), drag and drop a Fast Lookup ( Give the name Find active legal advisors) onto the window and map the fields as shown below:
- The next task is to check whether SocLegalAdvisors contains user records or not. To check this, we will use the Decision element. To do that, drag and drop the Decision element onto the canvas; it will open a new window for you. Enter details as follows:
- Name: Enter the name Check if there are any legal advisor exist
- Unique Name: This will be auto-populated based on the name.
- Description: Enter a meaningful description.
- Outcome: Enter the name Exist as EDITABLE OUTCOME. Select the variable {!SocLegalAdvisors} as Resource, then is null as Operator, and {!GlobalConstant.False} as the value
- Also, add Default Outcome as DEFAULT OUTCOME.
- Now we will use the Loop element to extract records from the SObject Collection Variable (SocLegalAdvisors) and store it in the SObject Variable (SocLegalAdvisor). Click on the Palette tab and drag and drop the Loop element onto the Flow canvas. Map the Loop element according to the following screenshot:
- The next step is to assign legal advisor’s to correct account and grant record access. For this, we will use Assignment element. Drag and drop an Assignment Element ( Give the name add users into a sov) onto the canvas and map the fields according to the following screenshot:
- Next, add all SObject Variables into a SObject Collection Variable. So that, at the end, we can insert the data into AccountTeamMember. Drag and drop an Assignment element ( Give the name Add sov into a soc) onto the canvas and map the fields according to the following screenshot:
- The final task is to insert data into the AccountTeamMember object. For this, we will use the Fast Create element. Drag and drop a Fast Create element onto the canvas and map the field according to the following screenshot:
- Use connectors to connect the elements used in the Flow. Finally, your Flow will look like the following screenshot:
- Once done, Save the flow and name it Add Members to Account Team, with Type: Autolaunched Flow. Do not forget to activate the Flow by clicking on the Activate button.
- The next step is to create a process, that will fire when a new account gets created. To do this, Navigate to Setup (Gear Icon) | Setup | Process Automation | Process Builder
- To create a new process from scratch, click on the New Button available on Process Management page. A popup will appear where you have to enter the Name (Use Auto add members to Account Team as the name), API Name and Description as shown in the screenshot below:
- Once you are done, click on the Save button.
- Click on the Object node to add object and then select the Account object. For the entry criteria, select only when a record is created, as shown in the screenshot below:
- Once you are done, click on the Save button.
- The next task is to add Process Criteria, so that process will only fire when Type equals Customer – Direct. To do this click on Add Criteria, enter Name, Type of action and set filter conditions, and follow the instructions below
- Once you are done, click on the Save button.
- Now we have to add an Immediate action into the Process to add Legal Advisors to Account Team for new accounts. Click on Add Action (Under Immediate actions), Select the type of action (In our case Flows), and then fill the values into fields to define the action – as shown in the following screenshot:
- Once you are done, click on the Save button.
- In the end, your Process will look like the following screenshot:
- Do not forget to activate the Process by clicking on the Activate button.
It’s time to test this feature
Next time, when an Account is created by the user, the process we created ( Using Process Builder) will fire and add Legal Advisors, to the Account Team.
I hope you enjoyed, and learnt, from the duo blogs, how to add, an individual team member, and multiple team members, to an Account 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.
Please feel free to add constructive comments and insights to the blogs.
Technical Editor and Proofreader: - Munira Majmunda
15 thoughts on “Getting Started with Process Builder – Part 81 (Auto Add Members to Account Team)”
manal ccc
i want to know if there is the possibility to add multiple member to account team because we put just one id in custom label ?
Rakesh Gupta
Use Custom Metadata Types and store to store multiple account member details
gouthamidev
Hi Rakesh,
I have a scenario where account team members will be copied to case team members when ever a new case is created using flow, my flow is getting failed due to inactive team members in account (account team members) can you help me how can we ignore inactive users when account team users were getting copied over newly created case.
Thanks.
Rakesh Gupta
I am so sorry for the delay in my response. You may have to use Record Lookup elements to filter out inactive account team member.
Kamal Thakur
Hi Rakesh, great article. But, is there any way I could reverse this process? Like Whenever I add Account Team Member on Account, I want somehow update the account record with some value. If you could share your view on this?
Rakesh Gupta
You have a very limited option. First – try to write Apex scheduled job which will run every night and perform the necessary action.
Second use Inline Visualforce page and Flow concepts.
Jen
Hi Rakesh,
Thanks for this guide. I am doing something similar but I am only creating when there is no team member with that role already in place. When there is one, I update the user on the team. My problem is my Fast Update does not work, I am checking the values I am passing to the SObject and it looks correct but update is not working. Insert works great.
Any thoughts?
Rakesh Gupta
Send me an email with details and screenshots here – info@automationchampion.com
Travis
Hello, great article! I read both this blog and part 80 on how to add multiple users to account teams – but I was wonder if it is possible to add multiple users from the user object, rather than the account object. So when a new user is created using “abc” profile, automatically add every user with “abc” profile to that users account team, while also adding the new user to the other users account team?
This is my current use case that takes me way longer than needed, especially when there are 30+ users with that profile.
Rakesh Gupta
Yes it is possible to achieve it using Flow and Process Builder. Can you provide a screenshot of what you’re seeing or error message you are getting?
Travis
I don’t have any examples or errors as I don’t know where to begin with this task. I am very new when it comes to flows so my knowledge is really minimal. I attempted to follow your instructions from this blog modifying the object to user rather than account and had no luck. No error of any kind, just didn’t work. Any help you could provide I would greatly appreciate!
Rakesh Gupta
Try something like this:
1. Create a Flow which will process your logic. Create a variable to store newly created userId (We will pass the value into it from Process Builder)
2. Using a Fast Loop find all users with the same profile
2.Now you have to use Loop and assignment and add all users into a specific list of type (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_useraccountteammember.htm)
4. Then use the Fast element to insert it
5. Create a Process Builder on the user object (Condition – when a record is created)
6. Then using an immediate action to launch a Flow (Autoaluanched Flow) and pass the value to variable UserId
Travis
Thanks for the reply – didn’t have much luck, but I’m assuming I’m doing something wrong. I’m not sure how to post screen shots so I’ll add steps to what I did:
Created UserID Variable with Text Data Type Input/Output
Created the “PinnacleProfile” formula based on the profile ID I created as a label
Created SObject TeamMembersVar which should be the list of Account Team Members
Created SObject UsersWithPinnacleProfileVAR which should be a list of users with the matching ProfileID “PinnacleProfile”
Created Collection Variable TeamMembers
Created Collection Variable UsersWithPinnacleProfile
Start >
Fast Lookup – User
IsActive = True
ProfileID = {!PinnacleProfile}
Variable: {!UsersWithPinnacleProfile}
Fields: Id
Next > Loop
Loop through {UsersWithPinnacleProfile} in Ascending order
Loop Variable {!UsersWithPinnacleProfileVar}
Next > Assignment – Name: Add users to TeamVar
{!TeamMembersVar.UserId} equals {!UserID}
{!TeamMembersVar.AccountAccessLevel} equals Edit
{!TeamMembersVar.ContactAccessLevel} equals Edit
{!TeamMembersVar.OpportunityAccessLevel} equals Edit
{!TeamMembersVar.CaseAccessLevel} equals Edit
Next > Assignment – Name: Collection to Variable
{!TeamMembers} add {TeamMembersVar}
> points back to loop
Loop to >
Fast Create:
Variable: {!TeamMembersVar}
Process Builder:
User Object
When Record is Created or edited
Formula evaluates to true:
ISNEW()
&&
[User].Profile.Name = “Pinnacle”
>
Initiate Flow
Flow Vaiable: UserID Field Reference [User].Id
Upon creating a new user with the Pinnacle Profile, I get the following error:
Unable to Access Page
The value of a parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information.
Any ideas?
Rakesh Gupta
Sorry for your inconvenience. Please mail me here at info@automationchampion.com
Manchun Kumar
Thank you for sharing great article related to salesforce. i want to contribute a article related to salesforce.