Hey Trailblazers, welcome back this week we are using flows for Chatter Group Notifications. We are inspired by the known issue: Process flow consisting of a chatter action “Post to Chatter” throws an error when deployed via change sets.  This one has been around for a while, essentially when attempting to changeset a process builder the Post to Chatter doesn’t in the new environment. Currently chatter groups are not deployed between environments, this means the Id’s are different in every environment and the process builder cannot find the group to post to. So what’s a developer to do?

Step 1: Chatter Group Notifications and Flows

In order for this to work you will need a chatter group with the identical name in each of the environments. For our use case we’re going with: Example Chatter Group. I know not super original. For the purposes of this iteration your group can be public or private. In our case we are choosing to use a public group for the sake of simplicity.

We will also need a flow and a process builder. Before you get too nervous I think you’re going to like our flow. Are you ready to start building?

Example Chatter Group

Step 2: Building Our Flow

Building our flow starts out with an Auto-Launched Flow. Before we start adding to the screen we want to create an input variable for us to pass the name of the Chatter group from the Process Builder. In our case we have named it varGroupName. It has a data type of text and is checked as Available for Input. Next up we are going to add an Action to the screen. You can find this under the Interaction section of the Elements tab. Drag it in to the screen, once open you will see a lot of prebuilt actions (hoping we get a chance to use these in the future). For now search for the “Post to Chatter” option.

If you are on your best behavior you’ll fill out the Label, Api Name and Description with meaningful information. If you are half asleep and convinced no one will read it, you’ll put in a value like we did and move along. In this case we went with Post to Chatter. From here you can define your message, for us it will be a simple “This is a sample post”.

For the Target Name or ID we are going to put in our input variable name. This allows us to use the same flow for multiple groups being notified. Finally, we will toggle the Target Type to Include. For this value we will put Group in the text box. We need to specify this as there is no Id prefix to look for and there are a lot of different locations Salesforce could go searching for text. Telling it to go check the names in the group object will make things alot easier.

After that, connect our nodes and we are already ready to activate our flow.

Input variable
Action Interaction

Step 3: Make Our Process Builder

Now that we have our flow ready to go we are going to switch over to making a Process Builder. This will be used to tell the notification flow when it is supposed to run. For our purposes we want a post to be added everytime a new Case is created. So we will start off by making our Process Builder on the Case object. With future scaling in mind we are going to start the process when a record is created or edited. 

For the criteria of the first node we are going to use the Formula evaluates to true option and just use the Isnew() syntax. Now for our action under Immediate Actions we will select the Action Type of Flows. Name the action appropriately and select the flow we just created. Notice the option for Set Flow Variables? Select Add Row. This will let you select the Input variable we created in the flow. Keep the value as String and enter the name exactly of the chatter group you made. Select Save. 

You are all set. Once the process builder is activated everytime we create a new case, we can see a new post in our chatter group. 

That’s all there is to it. I’m betting you are already thinking of how to expand this. Maybe by passing record variables so you can create links to the record itself? Or adding custom messages in the Process Builder? Or maybe you want to at mention a person or record instead? The possibilities are exciting.

If you have one you just can’t wait for let us know in the comments or visit the Lightning Flow Builder Group where you can see related articles, ask us a question or hang out with others using Lightning Flows. 

We hope to have more for you soon Trailblazers. So stay safe and we’ll see you on the trails.