Last Updated on December 5, 2020 by Rakesh Gupta
Oh sweet, I guess this is my 100th post on automation in Salesforce. I would like to thank everyone for their kind messages and support. I also wanted to share the good news, now Automation Champion blog is listed as a Process Builder resource on Trailhead along with awesome Jenwlee’s Salesforce blog, she has amazing contents on Process Builder and Flow.
Big Idea or Enduring Question:
- How can you automatically create a public group for a new account?
If you have a large Community implemented and a very active instance of Salesforce, you are probably leveraging Public Groups extensively. The public group represents a group of users. We can add any number of users to a public group. There is no limitation on the number of members per Public Group. It is the daily job of the Salesforce administrator to add or remove users to the Public group.
Objectives:
This blog post will help us to understand the following
- Create a Process Builder and Flow to auto-create a public group
- Understand how to use Flow to create a record
Business Use Case
Donna Serdula is working as a System administrator at Universal Containers (UC). They have just implemented a partner community to manage their partner’s related work better in one place and help them to sell more. As a part of the partner onboarding process, once both parties sign the contract. The next steps are to create partner account and contacts in Salesforce, to grant them partner community access. Currently, at Universal Containers they have few manual processes that they want to automate are mentioned below
- As a part of the partner onboarding process, the system administrator at Universal Containers manually creates a public group (Account Number for Name and DeveloperName) for each partner account. (Blog 56)
- Then add partner users from that account to Public Group, created in the preceding step. (Blog 57)
Automation Champion Approach (I-do):
I’m going to share a solution for the first requirement in this article and will publish another article for the second requirement i.e. Blog 57.
There are a few possible solutions for the first business scenario, but I’ll use Process Builder and Flow to solve it. Let’s take a minute’s pause here and understand Group objects in Salesforce.
Object Name | Details |
Group | It represents a set of user records. The group can contain individual users, other groups, the users in a particular role or territory, or the users in a particular role or territory plus all of the users below that role or territory in the hierarchy. |
Assumption: – I’m going to use Account Number as public group Label and Group Name. The reason behind it, we need a unique name for the public group name and the account number (Standard field on account object) is always unique for business. If you want to use something else like Account Name Plus Account Number or ID, then consider using the formula field.
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 Donna’s business requirement using Process Builder and Flow. We must:
- Lightning Flow Steps:
- Define flow properties for auto-launched flow
- Add a record variable to store account record details
- Add a create records element – create a public group
- Process Builder Steps:
- Define process properties
- Define evaluation criteria
- Define process criteria
- Set time for actions to execute
- Add action – flows
Step 1.1: Lightning Flow – Define Flow Properties
- Click Setup.
- In the Quick Find box, type Flows.
- Select Flows then click on the New Flow.
- Select the Autolaunched Flow (No Trigger) option and click on Next and configure the flow as follows:
- How do you want to start building: Freeform
- Click Done.
Step 1.2: Lightning Flow – Add a Record Variable to Store Account Record Data
A record variable is used to store all fields of a record. You can use the variable throughout your Flow. For example, while creating the record, performing an update, or with delete operations.
- Under Toolbox, select Manager, then click New Resource to store record details.
- Input the following information:
- Resource Type: Variable
- API Name: varRAccount
- Data Type: Record
- Object Account
- Check Available for Input
- Check Available for Output
- Click Done.
Step 1.3: Lightning Flow – Create a Public Group
The next step is to create a public group, as soon as an account gets enabled as a Partner account. For this, we will use the Create Records element.
–> Record Create element allow you to create a record in Salesforce using the values from the Flow.
–> Name refer to the group name, which corresponds to Label on the user interface.
–> DeveloperName is the unique name of the object in the API.
–> If you want to create a Queue then, set Type value equals to Queue.
- Under Toolbox, select Elements. Drag and drop Create Records onto the canvas.
- Input the following information:
- Enter Label the API Name will auto-populate.
- How Many Records to Create: One
- How to Set the Record Fields: Use separate resources and literal values
- Object: Group
- Set Field Values for the Group
- Row 1:
- Field: DeveloperName
- Value: {!varRAccount.AccountNumber}
- Click Add Row
- Row 2:
- Field: Name
- Value: {!varRAccount.AccountNumber}
- Click Done.
In the end, Donna’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: 50
- Interview Label: Create a public group {!$Flow.CurrentDateTime}
- Click Save.
Almost there! Once everything looks good, click the Activate button.
Our next task is to create a Process Builder on the Account object to start a Flow. To create a Process Builder on the Account object follow the below instructions
Step 2.1: Define Process Properties
- Click Setup.
- In the Quick Find box, type Process Builder.
- Select Process Builder, then click New.
- Name the Process and click the Tab button. The API Name will populate.
- As a best practice, always input a description.
- The process starts when A record changes.
- Click Save.
Step 2.2: Define Evaluation Criteria
- Click on the Add Object node to begin selecting the evaluation criteria.
- Select the Account object from the dropdown list.
- Start the process when a record is created or edited.
- Click Save.
Step 2.3: Define Process Criteria
- Click the Add Criteria node to begin defining the process criteria.
- Name the criteria.
- The criteria should execute actions when the conditions are met.
- Set Conditions
- Row 1
- Field: Account | IsPartner
- Operator: Equals
- Type: Boolean
- Value: True
- Row 1
- Select All of the conditions are met (AND).
- Click Advanced.
- Select Yes to execute the actions only when specified changes are made to the record.
- Click Save.
The reason why we would select the Yes checkbox for the question — Do you want to execute the actions only when specified changes are made to the record? — is to allow the Process Builder to execute the actions only if the record meets the criteria now, but the values that the record had immediately before it was saved didn’t meet the criteria. This means that these actions won’t be executed when irrelevant changes are made.
Step 2.4: set time for actions to execute
The next step is to set the time for scheduled action.
- Below Scheduled Actions, click Set Schedule.
- Set Field Values:
- Row 1:
- 0
- Hours
- After
- LastModifiedDate
- Row 1:
- Click Save.

Set Schedule
Step 2.5: Add Action – Flows
- Below 0 Hours After LastModifiedDate Scheduled Actions, click Add Action.
- Below Scheduled Actions, click Add Action.
- For Action Type, select Flows.
- Name the action.
- Select the flow we just created – Create a public group.
- Set Flow Variables:
- Row 1:
- Flow Variable: varRAccount
- Type: Field Reference
- Value: Select the Account record that started your process
- Row 1:
- Click Save.
–> The reason behind to use time-based action is to avoid MIXED DML error. DML operations on certain sObjects, sometimes referred to as setup objects, can’t be mixed with DML on other sObjects in the same transaction. It means we cannot perform DML Operation on both Setup and Non-setup objects in the same context of execution.
In the end, Donna’s Process will look like the following screenshot:
Almost there! Once everything looks good, click the Activate button.
Proof of Concept
If a sales rep or system administrator creates or updates an account as a partner account, Process Builder will fire and automatically create a Public Group.
- Navigate to the Account tab and identify an account that you want to enable as a Partner account. In this case, I want to enable Grand Hotels & Resorts Ltd as a Partner account.
- Click on Manage External Account and then, click Enable as Partner, as shown in the following screenshot:
- Wait for few minutes and then navigate to the public group (Click on Setup | Administer | Manage Users | Public Groups)
Formative Assessment:
I want to hear from you!
What did you learn from this post, is it relevant to you, and how will you modify the concepts taught in the post for your own business processes?
Make a post and tag me on Twitter @automationchamp, using #AutomationChampionPB.
6 thoughts on “Getting Started with Process Builder – Part 56 (Auto Create a Public Group For New Account)”
BBallBase
hi!
i´m trying to do something similar to this scenario, but the process builder should start after a non-admin user hits the entry criteria.
Is it possible for a non-admin to create a public group through flow/pb?
Rakesh Gupta
Yes it is possible. Could you please send me few screenshot of your automation?
azeersfdc
hello, when i was setting criteria for action.
like this
[Account].IsPartner Equals Boolean True
i m unable to set boolean, and i didn’t see any partner field, its show only partneraccount id, plz guid me
thanks in advance
Rakesh Gupta
Select ‘Partner Account’ – API name (IsPatner)
vrushali mali
Hello sir,
After creating a flow its giving an run time warning Create_New_Public_Group is not connected to anything. How to resolve this or what should i have to put there.
Rakesh Gupta
Ignore that warning message