Automatically Add Users to Public Group Using Salesforce Flow

Using Salesforce Flow, we can automate adding users to public groups instead of manually assigning them.

In this Salesforce tutorial, we will learn how to automatically add users to public group using Salesforce Flow, using real-time scenarios and explanations.

What are public groups in Salesforce?

In Salesforce, a public group is defined as a group that can be seen by all the users and employees who are working as a team. It is shared with everyone from our team, and it is also necessary to have this type of group in which all the members of the teams can easily control the queries.

Public groups consist of certain users and these are created to group users who have different profiles.

Let’s take a Scenario while working as a Salesforce Admin for a US-based Organization that provides software solutions. I was assigned the task of developing a flow. Whenever a New User is created, you have to assign them to the public group.

Prerequisite: We need a Public Group to which we can add newly created users. I have created a public group named My Group and as of now the group no members are assigned to the group.

We need a (Group API Name = My_Name) to create a flow.

You can read the whole article on How to Create Public Groups in Salesforce.

Automatically Add Users to Public Group Using Salesforce Flow

Automatically 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.

See also  How to Call Approval Process From Flow in Salesforce

1. Log in to the Salesforce Org. -> Click on the Setup. -> Home Tab. -> Search for Flows. You will see an option under Process Automation. -> Click on Flows.

2. Click on the New Flow button to create a new flow.

3. To add users to the public group, we must select the Record-Trigger Flow and click the Create button.

4. In our scenario, the flow should trigger when a New User is created. That’s why I have selected the User in the Object field. In Configure Trigger, I have selected A Record is Created because when we update the record, 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.

Add Users to Public Group Using Salesforce Flow

5. Then, we need to fetch the Group details that we created. For that, we need to select the Get Records element by clicking on ‘+ Add Element‘ and enter a Label and API Name into it.

In the Object field, select the Group object. To fetch the template, copy the Group Name and paste the copied group name in the “DeveloperName = My_Group” (the API Name of the created Group). After this, leave the other fields as they are and click on the Done button.

How to Add Users to Public Group Using Salesforce Flow

6. Now, we need to assign a newly created user to the Group. For that, add a Create Record element and enter a Label and API Name into it.

Then select One record to create and use separate resources and literal values to Set the record fields.

Salesforce Flow to Add Automatically Users to Public Group

7. Now, we are going to add a user to the group for that in the create a record of the Object select Group Member.

See also  How to Update Parent Record From Child Object using Salesforce Flow

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 User’s fields; you have to assign users 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).
Create a Flow to Add Users to Public Group in Salesforce

8. After setting up all labels and conditions, click the Save button to save the flow. For that, we need to enter the Flow Label. The API Name will automatically populate as we click the text box. The Description is optional; we can introduce our flow Shortly.

After Saving the flow, click on the Debug button. Then click on the Activate button; always remember to debug the flow before activating it. It’s good practice to use flow.

How tp Add Users to Public Group Using Salesforce Flow

9. After Activating the flow, let’s check how it is working; for that, go to the Home Page and Search for the user. Now, create a New User and save the newly created user. Here, you can see I have created a user named ‘Aiden Amstrong.’

You can read the whole article on How to create a user in Salesforce.

Add New User to Public Group Using Salesforce Flow

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

Automatically Add Users to Public Group in Salesforce Flow

This is how we can automatically add users to public groups using Salesforce Flow.

Conclusion

In Salesforce CRM, flows help enable the automation of various processes; with this automation, we automate the process of adding newly created users to the public group.

See also  How to Bypass Validation Rules Using Salesforce Flow

In the above steps, we have seen what is a public group and how to automatically add users to a public group using Salesforce Flow using real-time scenarios and explanations.

You may like to read: