Getting Started with Salesforce Flow – Part 36 (Automatically Add a New Users to a Chatter Group)

Getting Started with Salesforce Flow – Part 36 (Automatically Add a New Users to a Chatter Group)

Last Updated on January 4, 2021 by Rakesh Gupta

To understand how to solve the same business use case using Process Builder. Check out this article Getting Started with Process Builder – Part 24 (Automatically Add User to a Chatter Group).

Big Idea or Enduring Question:

How do you automatically add users into a Chatter Group? 


This blog post will help us to understand the following

  • Use After-save Record-Triggered Flow add users to a chatter group
  • Add a Time-dependent action in After-save Record-Triggered Flow
  • What is a MIXED DML error and how to avoid it?
  • Monitor Time-based flow queue

Business Use case

Brenda David is working as a System administrator at Universal Containers (UC). Her next assignment is to create a process to auto add a new user to Chatter Group (UC Internal Announcements).

Automation Champion Approach (I-do):

The process of creating a new user can involve many steps that have to be repeated for each person. This can become time-consuming for admins. However, this process can be made easier with automation.

While this can be solved using various automation tools like Apex or Process Builder, we will use After-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario. 

Before proceeding, ahead, understanding CollaborationGroupMember objects in Salesforce. It represents a member of a Chatter group.

Field Name Details
CollaborationGroupId Represent Id of the Chatter Group
MemberId Represent Id of the User (Group member)

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 4 steps to solve Brenda’s business requirement using After-save Record-Triggered Flow. We must:

  1. Create a chatter group
  2. Find the chatter group Id
  3. Creating a custom label to store chatter group Id
  4. Salesforce Flow
    1. Define flow properties for record-triggered flow
    2. Add a scheduled path
    3. Add a create records element to add a new user to a Chatter group 

Step 1: Create a Chatter Group

  1. Navigate to App Launcher and click on the Groups.
  2. Clicks on the New button. 
  3. Name the Group and make sure to select the Private Access Type.
  4. Click Save.

Step 2: Find the Chatter Group Id for UC Internal Announcements 

The next step is to find out the Id of the chatter group UC Internal Announcements. One possible workaround is to use the Developer Console. 

  1. Click Setup | Developer Console 
  2. In the Query Editor, run the following SOQL query 
    1. Select id, name from collaborationgroup where (name=’UC Internal Announcements’)
  3. Make sure to copy the Id. 

Step 3: Creating a Custom Label to Store Chatter Group Id

  1. Click Setup.
  2. In the User Interface, type Custom Labels.
  3. Click on the New Custom Label button.
  4. Enter Short Description the Name will auto-populate. 
  5. Now enter the UC Internal Announcement chatter group id in the Value.
  6. Click Save.

Step 4.1: Salesforce Flow – Define Flow Properties 

As we have a requirement of creating a record in (CollaborationGroupMember) when a user is created. This is why we have to use the After-save flow on Opportunity.

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
    2. Trigger the Flow When: A record is created
    3. Run Flow: After the record is saved
    4. Object: User
  5. Select All Condition Are Met (AND)
  6. Set Conditions
    1. Row 1
      1. Field: User | IsActive
      2. Operator: Equals
      3. Value: {!$GlobalConstant.True}
  7. Click Done.

Step 4.2: Salesforce Flow – Add Scheduled Paths

When DML operations on certain sObjects sometimes referred to as setup objects (such as a User Object), along with, on the non-setup object (such as Accounts, CollaborationGroupMember), in the same transaction, then, a Mixed DML error is thrown at a User.

The Mixed DML error is generated – when a User performs DML actions on Setup and non-Setup Objects in the same transaction -because some sObjects affect the user’s access to records in the org. Therefore, a user must insert or update these types of sObjects in different transactions to prevent operations from happening with incorrect access-level permissions. For example, a user cannot update an account, and a user role, in a single transaction. However, deleting a DML operation has no restrictions (reference Salesforce help).

That’s why we are going to add a time delays to avoid MIXED DML Errors.

  1. Under Start, select Add Scheduled Paths (Optional).
  2. Under SCHEDULED PATHS, click on the  New Scheduled Path.
  3. Under Scheduled Path Details, enter the Label the API Name will auto-populate.
  4. Time Source: User: Created Date
  5. Offset Number: 0
  6. Offset Options: Hours After
  7. Click Done.

Step 4.3: Salesforce Flow – Create Records – Add New User to Chatter Group ‘UC Internal Announcements’ 

The next step is to add new users to the chatter group. We will use the Create Records element. 

  1. Under Toolbox, select Elements. Drag and drop Create Records onto the canvas. 
  2. Input the following information:
    1. Enter Label the API Name will auto-populate.
    2. How Many Records to Create: One
    3. How to Set the Record Fields: Use separate resources, and literal values
    4. Object: CollaborationGroupMember
    5. Set Field Values for the Group Member 
    6. Row 1:
      1. Row 1:
        1. Field: CollaborationGroupId
        2. Value: {!$Label.UC_Internal_Chatter_Group_ID}
      2. Add Field
      3. Row 2
        1. Field: MemberId
        2. Value: {!$Record.Id}
  3. Click Done.

In the end, Brenda’s Flow will look like the following screenshot:



Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 51
  5. Interview Label: Add User to a Chatter Group {!$Flow.CurrentDateTime}
  6. Click Save

Almost there! Once everything looks good, click the Activate button.

Proof of Concept

Now onwards, if a system administrator creates a new user, then Process Builder will automatically trigger and add the user to the UC Internal Announcement Chatter group.

  1. Now create a new user via the UI
  2. Once the user is created, they are automatically added to the chatter group UC Internal Announcements within a few seconds, as shown in the following screenshot:

Monitor Your Schedule Flow

To monitor Flows that are scheduled, navigate to the following path: 

  1. Navigate to Setup (Gear Icon) | Environments | Monitoring | Time-Based Workflow.
  2. Now look for your Scheduled Flow job displaying information as shown in the following screenshot:

  3. Use the Delete button to delete the time-based Flow job from the queue.

Independent Practice (You-do):

Automatically add a user to a different user group based on their role or profile. 

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? 

Let me know by Tweeting me at @automationchamp, or find me on LinkedIn.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

92 thoughts on “Getting Started with Salesforce Flow – Part 36 (Automatically Add a New Users to a Chatter Group)

  1. I’m in the process of testing this, and when I create a new user I get the error “Workflow Action Failed to Trigger Flow
    The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 301290000004RIe. Contact your administrator for help.”

    I have the workflow that sets the Start field to TRUE and the Process Builder that is supposed to add them to the Chatter Group and then set Start to FALSE. Any ideas?

  2. Hi Rakesh, I can’t seem to activate my flow I am working in sandbox any ideas? Its an autolaunched flow in the Flow type but I can only Open or Run this and the status is draft I am a system admin? Any thoughts as I cannot do the process builder flow to until this is active.

      1. Ok I got this and I have it all set up but its still not updating the group. I have an active flow, I have an active workflow rule and I have an active Business process. The check box is being updated but the group is not having the user added. any help much appreciated.

  3. Hi Rakesh

    Got this working nicely for me, really useful.

    I have a question that I wondered if you could help me with though.

    Is it possible to have a single flow consider different criteria and allocate a user to different groups, or none at all? Or would I need multiple versions of these steps?

    E.g. I wanted all users to be added to the group “UC Internal Announcement”, and only those with a profile of “Customer Services” to be added to a “Customer Services” group. Is that posssible?

    1. Yes this is possible, I modified Rakesh’s plan to incorporate this. You just need to pass through Profile ID’s in a variable, and add a decision based on whether or not that profile is a match with the user. If it is a match, it would go down the Yes branch of the decision and add the user to the chatter group, if it’s a No then it would move on to the next decision/action.

      1. This all made perfect sense, and has really helped me get to grips with using Flow 🙂
        Thanks Rakesh and Chris.

        However, I can’t seem to get it to work. I get no errors or anything, the user just never gets added to the Customer Services group. The user is added to the main one, no problem. But try as I might I can’t get them into the other group, depending on the profile ID.

        The Collaboration Group ID is definitely correct (and the group is open not private). The Profile ID is also definitely correct.

        The Decision element of the flow exactly matches your screenshot. Even the Default Outcome section that shows “Noo”! 😉

        The second record create also matches the first one exactly, apart from it uses the new Collaboration Group ID. Are there any other parameters I need to set in this step?

        Finally, the Process Builder part, I added the Profile ID part as a Flow variable, in addition to the existing User ID. All correct updated versions of the Flow and Process Builder are activated.

        Think I’ve covered it all! Is there anything I have missed? As I say, I’m new to Flow so I feel this is the area I am most unsure of.


  4. In Step 5) Next task is to add one Immediate Actions i.e. Launch a Flow, Please refer to the following screenshot for more details.

    No option to Set Flow Variables.

    Or I’m missing something.

  5. Hi Rakesh,

    When it comes to step 4 – add new field update, I can’t see “Start” field available. Is that a custom one? Do I need to create it?

    Thank you


  6. From step 6 (i.e. workflow Rule2) you have to migrate it to Process Builder, follow the below Instructions
    1) Navigate to Setup | Build | Create | Workflow & Approvals | Process Builder and click on the New button to create the new Process
    2) Enter the Process Name, Description and API Name, Once done click on Save button as shown in the following screenshot
    3) Now Click on Object then Select the User Object and Evaluation Criteria for Process, as shown in the following screenshot
    Once done click on Save button
    4) Next step is to add Process Criteria, To do that Click on Add Criteria, Please refer to the following screenshot for more details
    Once done click on Save button.
    5) Next task is to add one Immediate Actions i.e. Flows, Please refer to the following screenshot for more details
    Once done click on Save button.
    6) Final Step is to add one field update Immediate action to set Start flag to False, We will use update a record action in the Process, Please refer to the following screenshot for more details
    Once done click on Save button.
    7) Finally your Process will look like the following screenshot
    8) Activate the Process. After you activate a process, you can no longer edit that process

    1. Rakesh,
      Thanks for all the detailed info. I have a problem while trying to add the Flows in the Process Builder. I don’t find my activated flow under the “Flows” in the Process Builder. What could be the reason?


  7. Hello Rakesh,

    Your steps work great but have couple of questions.

    it works great when adding users but if i deactivate a user and re-activate him it is giving error.
    Why are we creating Start custom check box field on user object?
    Any idea on how to create this using “Process builder” which will be new flows in future according to Salesforce team.

    Thanks for your help!

    1. Hi Ravi,

      1) Make sure that you have added one Immediate action on second WFR to update Start Check-box to False.
      2) We are using the Start check-box to invoke the flow after certain time period, because Flow triggers aren’t available as time-dependent workflow actions.
      3) I am going to post an article, it will help you to understand how to migrate Flow trigger to Process builder.


  8. Your blog post was a great help in getting this set up, and I got it working to some extent. However, I would like the Flow to only add the user to Chatter Groups if they are not already a member. The reason for this is that I would like to trigger the flow via a checkbox for all of my existing users to ensure that they get added to the appropriate chatter groups. when I run the flow normally, it errors out if they are already a member of one of the chatter groups and the flow does not work.

    I tried using Record Lookups to the chatter groups and decisions to incorporate multiple flows for different users, but it doesn’t seem to work. Any ideas on how this could be done?

      1. Hi Rakesh,

        Thanks for your quick response. The steps in your document are what I had already followed (see my document below) but with an additional chatter group add. However, I keep getting this error message when running the flow:


        Encountered unhandled fault when running process User_Add_User_to_Chatter_Groups/301M0000000D0fF exception by user/organization: [Erased]/{4} Source organization: [Erased] (null) UPSERT — UPSERT FAILED — ERRORS : (INVALID_CROSS_REFERENCE_KEY) invalid cross reference id — for SFDC record with ID : null,

        caused by element : FlowRecordCreate.Add_user_to_Salesforce_System_Updates_Chatter_Group

        caused by: UPSERT — UPSERT FAILED — ERRORS : (INVALID_CROSS_REFERENCE_KEY) invalid cross reference id — for SFDC record with ID : null,

        Salesforce Error ID: 652841348-188537 (-505174119)”

        I can’t understand why this is happening. To trigger the flow, I’m using a Flow Trigger passing over the following parameters – ‘UserID = {!Id}’ on edit of the User Record.

        Do you have any ideas?

      2. Hi Rakesh,

        Ignore my last post, I was making a silly mistake! I realised I had an incorrect chatter group ID on the Record Create section. Not sure how I missed that!


      3. I have tried this but I keep getting API errors like this:

        An error occurred at element Check_User_Current_Chatter_Group_Memebership.
        ; nested exception is: common.exception.ApiQueryException: ((CollaborationGroupMember.CollaborationGroupId = ‘0F980000000LTl5’) AND (CollaborationGroupMember.MemberId ^ ERROR at Row:1:Column:146 invalid ID field: 0.

        Any idea what I have done wrong?

  9. Hi Rakesh, a colleague and I both tried this and we get the following error after doing a debug:

    FLOW_ELEMENT_ERROR|UPSERT — UPSERT FAILED — ERRORS : (MIXED_DML_OPERATION) DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): CollaborationGroupMember, original object: User — for SFDC record with ID : null, |FlowRecordCreate|Add_user_to_Chatter_group

    The message on the UI is:

    Workflow Action Failed to Trigger Flow
    The record couldn’t be saved because it failed to trigger a flow.
    A flow trigger failed to execute the flow with version ID 301A00000008fMm.
    Contact your administrator for help.

    My org is on Winter ’15. Do you have any thoughts on this?

  10. Rakesh,

    Thanks for this, and all of your posts. I have a Flow that I run manually after creating the User and it creates a Contact for the User, sends them a Welcome email, and adds them to one of two Chatter Groups with a single click. This piece, adding them to the Chatter Group, was the last one and this post contained exactly what I needed to get it up and running!

  11. I might be crazy but can you try this in a new release? I’m working with SFDC now and suspect they actually changed it so we can’t do more than 1 data change in these.. this solution no longer works in the new release for me… Idk if this would help you:
    Salesforce may not allow you to do a Setup change and a Data change in the same transaction unless one of them is a future change. So in that case, creating a user = setup change, and adding a record to the object for the ChatterMember is also considered a data change. This causes the Mixed DML message.

  12. How do I add a parameter? For example, I only want to do this where License = Salesforce…. I’m not sure where I would set that, and if I could within the first variable or perhaps another?

    Issue: When we activate a platform license for example (someone who doesn’t have access to chatter) this flow keeps us from activating that new user.

    All in all this is a great feature and I can’t wait to explore all the possibilities. Thank you!

    1. Good catch. To solve your requirement
      –> In workflow Rule entry criteria you can add conditions like Profile like A, B & C (Mention all profiles for license type Salesforce), So workflow will trigger only when it match with the profile you mentioned.

      1. You got me! License isn’t a field we can use as criteria within the UI (just API as far as I know) so I think we might need to add it to the flow.. What do you think?

      2. Rakesh, I have tried adding Profile ID Equals then list one ID so that the process only triggers for one Profile but with this the process wont trigger. Without the profile ID requirement it does work. Any ideas?

  13. 4) Add one Immediate Workflow Actions i.e. New Flow Trigger and Select Flow and set Variable (UserID) value as show in the below screenshot

    I cannot activate this flow as it does not have a Start item. If I just have the Record Create item (technically the start item is a Workflow rule) how do I reflect that in the Flow so it lets me activate?

    1. Lol Please disregard. They have updated it so all you need to do is click the green circle with a white arrow (upper right side) on the element in the flow designer, then you get the “Activate” option, then can add, then will work!

  14. Thanks Rakesh for the quick response.
    SInce i am new to this flow designer, just wanted to know is their any other way where i can call this flow(whatever i made)
    I need to add some notifications to a group once my custom field update meets the criteria. Apart from the above method , by creating a flow trigger from workflow.
    Can i create other flow and tagged that as start element and joined my earlier flow to that

    1. You can now launch a trigger-ready flow with these methods, which are generally available.after summer’14 release
      1) The Apexstart() method
      2) A custom button or link
      3) The flow URL
      4) The Run button in the Cloud Flow Designer

  15. Rakesh, my only options when adding a “Immediate Workflow Action” are;

    1. New Email Alert
    2. New Field Update
    3. New Outbound Message
    4. Select Existing Action

    I don’t see an option to add a Flow Trigger. Any thoughts?

  16. Hi Rakesh, thank you for the post, quick question, I am trying to activate the flow. I assume I have to do this before I create a wrokflow with the immediate Workflow Actions (flow) The flow is now inactive, I am geeting General Warning (1) Add user to the Chatter Group (record Create) is not connected to anything. How can I activate the flow?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.