As a Salesforce admin, I’m responsible for managing user access, permissions, and organization security. In our organization, there are different roles such as Sales Employee, Manager, and HR.
Now, according to the user role, I need to assign that user to the respective group. For example, if the user is in the Sales Employee role, then I need to add them to the Sales group.
Now, the requirement is that whenever a new user account is created or an existing account is updated, I want to automatically add the user to the public group according to the user’s role.
In this article, we will learn about how to add users to public group using Salesforce Flow. In this, I will explain what a public group is and how we can add newly created user to the public group according to their roles.
What is a Public Group in Salesforce?
In Salesforce, a public group is a collection of users that enables easy sharing of records or setting of permissions for multiple users at once, rather than assigning access individually.
For example, we have a public group named ‘Support Team’ that includes five support users. Now, instead of sharing a case record with each user, you can share it with the group.
Below you can see the public group that I created for sales and service users. Now using the flow, I want to automate the process when any new user is created or an existing user is updated. According to their role, they should be added to the group.

We also require the User Role ID, which we will use in the flow to determine which public group should be assigned to the specific user role.
For that, I used the SOQL query to retrieve the IDs of the user roles.

Add Users to Public Group Using Salesforce Flow
Using the above scenario and the following steps, we can automatically add users to a public group using Salesforce Flow.
Click on the Setup. -> Home Page. -> In the Quick Find Box, Search for Flows. You will see an option under Process Automation. -> Click on Flows.
In the flows setup window, click on the button New Flow -> Start From Scratch -> select the Record Trigger Flow -> Next.
In the start element, we have to select the object on which we want to perform automation. In our scenario, the User is a triggering object.
In Configure Trigger, I have selected A Record is Created or Updated because when we create or update a role, the flow should trigger.
Then, we don’t need to Set Entry Conditions. We are going to add a newly created user to the public group, so we have to select Optimize the Flow for Action and Related Records.

Next, we need to select the Get Records element by clicking on ‘+ Add Element‘ and then enter a Label and API Name into it.
To retrieve the public groups that we have created for this scenario. Select the Group object.
Then, to Filter Records for the object, we need to add a condition:
- In the Field option, you will see all fields from the Group. There, we need to select the Developer Name.
- Equals operator.
- In the Value, we need to select which group we want to retrieve from the object.

To assign the public group according to the role, we need to add a Decision element that checks the user’s role. Then, by adding the Create Record element, we will assign the respective public group to that user.
In this condition, we need to provide the User Role ID that we retrieve using a SOQL query. For this, you need to add the number of outcomes corresponding to each role.

Now, we need to assign a newly created user to the Group. To do this, add a Create Record element and enter a Label and API Name into it.
Now, we are going to add a user to the group. For that, in the “Create a record of the Object” section, select Group Member.
Enter the following conditions for Set Field values for the Group Member. In the Field, you will see the Group Member’s fields, and in Value, you will see the User’s fields; you have to assign the User’s field to the group member field as follows:
- GroupID (From Group Member) = GroupID (From Get Record Element).
- UserOrGroupId (From Group Member) = UserID (From User Object).

Now we are ready to save the flow. For that, click the Save button, provide the flow Label, and the API Name will be automatically populated.
After that, always debug the flow before activating it to ensure that the working flow is correct and that there are no runtime errors. Then activate the flow.

In this way, we can automate the process of adding a user to the public group using Salesforce Flow.
Proof of Concept:
In the screenshot below, you can see the users that we have in the Sales Group. Now we will update the existing user role for their account.

Now, we will test the flow to see if it adds the new user to the respective public group. To do that, navigate to the User details page. Open any Active User record.
- Now, I update the User Role according to our scenario and save the record.
- I have assigned the Sales Employee Role to the John Joy user, which means he should get added to the Sales group as per the logic we defined.

Here, as you navigate to the Public Group, you can see that the user we just created has been assigned to the group.

This is how we can automatically add users to public groups using Salesforce Flow.
Conclusion
I hope you have got an idea about how to add users to a public group using Salesforce Flow. In this, I have explained what a public group is and how we can add newly created user to the public group according to their roles. This helps us automate the process of adding a user to the respective group based on their role.
You may like to read:
- Assign Permission Set to New Users Using Salesforce Flow
- Send An Email to User and Public Group Using Apex in Salesforce
- Create a Public Group and Share Report With Group in Salesforce
- Create a Scheduled Path in Salesforce Flow
- Auto-Assign Records to Users Using Salesforce Flows
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.