Topics are a great way to organize or increase post and comment visibility. For example, if you post that you’re working on a presentation for Dreamforce’14, you might want to add the hashtag topic #Dreamforce14 or #DF14 in your updates. Anyone can click on these topics to find out more information about Dreamforce’14 and see what people and groups are talking about Dreamforce’14. After Summer’14 Salesforce allows you to the Delete topic from Salesforce User Interface, but not merge two different Chatter Topics. I have never found any apps or out of the box, solution to merge two different Chatter Topics. In this article, we will develop the same app without using code.
Business Use Case
People at Universal Container are using Chatter hashtag to organize their posts. Management in Universal Container wants to develop an application so that their system administrator can merge two different Topics (For example ABC & DEF).
Solution for the above business requirement
To solve above business requirement, we will use Visual Workflow and fire this flow will use Custom Link. Before going ahead with the solution, you have to understand about TopicAssignment Object. It represents the assignment of a topic to a specific feed item or record. Below are the key fields from TopicAssignment object
Field Name | Details |
EntityId | Identifier of the feed item or record. |
TopicId | Identifier of the topic. |
To develop this application follow the below instructions
1) Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
2) Click on New Flow, it will open flow canvas for you. Create Three variable
- Topics (SObject variable – TopicAssignment type )
- GetAllPostFromTopics and NewTopicDetails (SObject Collection Variable – TopicAssignment type)
3) Drag and drop a Screen Element ( Give the name Merge Topics) onto the window and add two fields with below detail
Name | Data Type | Required |
Old Topic ID | Textbox | Yes |
New Topic ID | Textbox | Yes |
It will look like the below screenshot
4) Drag and drop a Fast Lookup ( Give the name Get all post from Old Topic ) onto the window to get all posts, links etc from old Chatter Topic and map the fields according to below details
- Select Object TopicAssignment
- TopicId= {!OldTopicID} [OldTopicID is nothing but Screen Input field], Save Id of records into any variable in our case it’s {!GetAllPostFromTopics} Sobject Collection variable. You can take help from the following screenshot
5) Drag and drop a Record Delete ( Give the name Delete Old Topic) on the window. Under object select Topic, and map ID–> {!OldTopicID}, as shown in below screenshot
6) Drag and drop a Loop Logic (Give the name Extract post one by one) on the window and extract post from Sobject Collection variable and pass it to Sobject variable, as shown in the below screenshot
7) Drag and Drop Assignment Logic (Give the name Update Topic ID) on the window and assign value of Screen input {!NewTopicID} to Sobject variable variable {!Topic.TopicId} so that all posts from an Old Topic to assign New Topic. Take the help from the below screenshot
8) Drag and Drop Assignment Logic (Give the name Add all posts Into New Collection) on the window and assign value from Sobject variable {!Topic} to Sobject Collection variable {!NewTopicDetails} so at the end of for loop we will have all posts from Old Topic into One collection with updated Topic ID. Take the help from the below screenshot
9) Finally drag and Drop Fast Create (Give the name Record Create) on the window to add all posts from an Old Topic to New Topic, It means we are creating their reference in TopicAssignment object, as shown in the below screenshot
10) Finally our flow will look like the below screenshot
11) Save the flow with name (Merge Chatter Topic) and close the canvas.
Add Visual workflow into the home page component
We can call Flow from the custom button, link, sub-flow, Visualforce page, Apex start() or using Flow Trigger workflow action. Here we will call our flow using Custom Link available in the homepage component. To do that, follow below instruction:
1) Create custom link from Name | Setup | App Setup | Customize | Home | Custom link
2) Add custom link in the Home page component
3) Add Home page component into the Home page layout
It’s time to test this feature
1) In this demo, I will Merge Chatter Topic Dreamforce (Old) with Salesforce (New)
2) To get Topic ID, for Topic Dreamforce take a look at the below screenshot
3) To open this app click on “Merge Chatter Files” link available on the homepage, and fill the details you can take help from below screenshot
4) Now enter old and New Topic ID, In my case Dreamforce is Old Topic and Salesforce is New Topic and click on Next Button, as shown in the below screenshot
Your all Posts Including Status Update, links, polls or files are moved to new Topic.
Note: – I will suggest you to Implement this first on your developer org, test it and then move it to Production. Let me know if you have any difficulty to Implement it.