Chatter Group is playing a key role in internal collaboration for an organization. Peoples who are members of a Chatter group they can post Status, link, file etc.
Business Use Case
Universal container management wants to delete the posts from a Chatter Group ( Salesforce project ) that created before today.
Solution for the above business use case
There are few ways to solve above business requirement, that I am aware of
- Delete Manually
- Data Loader
- Visual Workflow
Here I will discuss a way to delete Chatter post for certain groups by using visual workflow. Before going ahead you have to understand about few object that represents Chatter Group and Chatter feed.
CollaborationGroup: – This object represents a Chatter group.
CollaborationGroupFeed: – This object represents a single feed item on a Chatter group feed.
Create Visual workflow
We will create a screen from where the user can select a Chatter Group and the entered date, so the post will delete according to date and group.
Now we will go ahead and create flow, to do this follow the below instructions
- Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
- Click on New Flow, it will open flow canvas for you
- Drag and drop a Screen ( Give the name Group list) on window, and click on Add a Field as shown in below screenshot
- The next step is to show Chatter group name dynamically in the drop-down, to do that add field Drop-down (Name – Show list of groups) and create new dynamic choice, as shown in below screenshot
- Enter Choice Unique Name, Select CollaborationGroup option under create a choice for drop-down, under filter criteria select id <> {!$GlobalConstant.EmptyString}. Store Group id to a variable in my case its GroupID, you can take help from below screenshot. Once done click on Ok to save it
- Now we will create a Date field to take user input. According to date entered by user we will delete all feed before that date. Drag & drop a Date field into the screen (Enter label – Enter date) and make it required ass shown in below screenshot
- Now we will delete the feed item from chatter group. To do that drag and drop Record Delete into the screen. Enter Name, Unique Name, from delete drop-down select CollaborationGroupFeed object. Navigate to filter section and map LastModifiedDate –> Enter date (Input choice from screen), ParentId–> GroupID (we store groupid in screen 1). As shown in below screenshot
Note: -Parentid represents ID of the group that is tracked in the feed.
Connect both the item and set screen as start element, as shown in below screenshot
Add Visual workflow into the home page component
We can call flow from a custom button, link, sub-flow, Visualforce Page. Here we will call our flow from the home page component. To do that follow below instruction
- Create custom link from Name | Setup | App Setup | Customize | Home | Custom link
- Add custom link in the Home page component
- Add Home page component into the Home page layout
It’s time to test this feature
Now we will delete all post from Chatter Group ( Salesforce project ) as per business use case.
To launch flow go to home tab and click on custom link, as shown in below screenshot
it will launch flow, select Chatter group and enter date as per your choice and click on Next, so flow will delete all post prior to date entered. you can take help from below screenshot
It will delete all post from a group you selected.
Use this app on Salesforce1
To use this app on Salesforce1, create a Visualforce Page, And embed your Flow and crate a Visualforce Tabs to call it. Belw is the sample code for your reference
<apex:page >
<br/>
<Center><Font size =”6″ color =”orange”>Chatter Group Feed Cleansing</font></Center>
<br/><br/>
<flow:interview name=”Group_member”/>
</apex:page>
It will look like below Screenshot on Salesforce1 App
Note :- If you want to resize (limit) flow screen then use class. below is the sample code