Often, a business will want to auto-post the details of records to Chatter groups. This is possible through Apex code, but there is a way to achieve it without code – that is, Process Builder. Process Builder has a specific action for this, called Post to Chatter. You can auto-post the record details to a Chatter group using the following methods:
- Process Builder
- A combination of Flow and Process Builder
- A Flow and an Inline Visualforce page
Let's look at a business scenario. Suppose that Helina Jolly is working as a system administrator at Universal Containers. She has received a requirement to post opportunity details to the Sales Executive Chatter group, whenever an opportunity gets created with an amount greater than $1,000,000.
Follow these instructions to achieve this using Process Builder:
-
Create a public Chatter group, named Sales Executive.
- To create a process, navigate to Setup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder, click on the New button, and enter the following details:
- Name: Enter Post Opportunity Information to Chatter Group
- API Name: This will be auto-populated, based on the name
- Description: Write some meaningful text, so that other developers or administrators can easily understand why this process was created
- Once you are done, click on the Save button. This will redirect you to the process canvas, which will allow you to create or modify the process.
- After defining the process properties, the next task is to select the object upon which you want to create a process and define the evaluation criteria. For this, click on the Add Object node. It will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
- Object: Start typing, and then select the Opportunity object.
- Start the process: For Start the process, select only when a record is created. This means that the process will fire only at the time of record creation.
- Recursion – Allow process to evaluate a record multiple times in a single transaction: Select this checkbox only when you want the process to evaluate the same record up to five times in a single transaction. In this case, leave the box unchecked.
- Once you are done, click on the Save button.
- After defining the evaluation criteria, the next step is to add the process criteria. Once the process criteria are true, the process will execute the associated actions. To define the process criteria, click on the Add Criteria node. It will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
- Criteria Name: Enter Only when amount > $1M in Criteria Name.
- Criteria for Executing Actions: Select the type of criteria that you want to define. You can select either Formula evaluates to true, or Conditions are met (a filter to define the process criteria), or No criteria-just execute the actions! In this case, select Conditions are met.
- Set Conditions: This field lets you specify which combination of the filter conditions must be true for the process to execute the associated actions. In this case, select a Value greater than $1,000,000.
- Conditions: In the Conditions section, select All of the conditions are met (AND). This field lets you specify which combination of the filter conditions must be true for the process to execute the associated actions.
The dollar sign ($) is not required when entering the amount. What we enter as criteria can be just the raw number – that is, 10,000,000. The system will add the currency for us.
The process criteria will look as follows:
- Once you are done, click on the Save button.
- Once you are done with the process criteria node, the next step is to add an immediate action to post the opportunity details to the Chatter group. For this, we will use the Post to Chatter action, available in Process Builder. Click on Add Action, available under IMMEDIATE ACTIONS. This will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
- Action Type: Select the type of action. In this case, select Post to Chatter.
- Action Name: Enter Post to Sales Executive Chatter group in Action Name.
- Post to: This allows you to select the Chatter Group, or User, or Current Record, where you want to post the opportunity details. From the drop-down menu, select Chatter Group. Then, start typing the name of the Chatter group in the textbox, and select Sales Executive.
- Message: Enter the message that you want to post. You can also use the fields above the textbox to mention a user or group, add a topic, or insert a merge field into the message.
Immediate actions will appear as shown in the following screenshot:
- To insert fields, click on Insert Field. To mention a user or Chatter group, use the Mention a user or group textbox. Finally, to add a topic, use the Add topic textbox. Once you are done, click on the Save button.
- Once you are done, the final step is to activate the process. Click on the Activate button, available on the button bar. Finally, the process will appear, as shown in the following screenshot:
From now on, if users create an opportunity with an amount higher than $1,000,000, the process will auto-post a textpost to the Chatter group Sales Executive, which will look as follows:
You can also achieve this through a combination of Flow and Process Builder. If you use Process Builder, you can only post a textpost, whereas if you use Flow, you can post a linkpost, textpost, and so on. It will also allow you to set CreatedById. For this, use the Record Create element and the FeedItem object.
If you have embedded the Flow in a Visualforce page, you will need to use the Inline Visualforce page on the opportunity object in order to achieve it.