function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Marcel dos SantosMarcel dos Santos 

Implementing question form in Salesforce Communities

I am implementing a pixel level customized Salesforce Community. To be able to have the forms, divs and fields we want, I am using a Visualforce + Tabs template and writing Visualforce code for all the pages and forms I need.

Now I'm starting to implement pages and forms to list questions and answers, post questions, vote for questions and best replies, etc. To be able to display all the fields and categories the way we want, I'm gonna have to query Salesforce object using SOQL. What is not clear to me is what objects to use. From what I've read in forums and Salesforce Communities documentation, the right way to do it is to work with Chatter Answer objects (Question, Reply, QuestionDataCategorySelection), etc. Another option I see for that is using API objects like Topic, TopicAssignment, FeedItem and FeedComment.

I have two questions:
1- What is the right approach to implement a question form and list in a Salesforce Community from the scratch? Although I feel like the right way to do it is using Chatter Answers objects, I tried a Napili template community before and the questions and topics I created were saved in FeedItem, FeedComment, Topic and TopicAssignment objects.
2- As I can use only one CategoryGroup per Community (zone), if I use Question, Reply and QuestionDataCategoryObjects, am I restricted to only one category per question?
Best Answer chosen by Marcel dos Santos
desmoquattrodesmoquattro
Marcel - Think of Chatter Answers, the Q&A tab that surfaces it, and the Question object that supports them as the legacy solution here. Questions in the Feed (which is used by Napili) is the go-forward solution. So if at all possible I'd strongly advise using FeedItem and FeedComment as the underlying objects to your solution, and using the Connect API (https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/) (which has extensive Chatter tooling and helps you avoid limits) as your method to get to them. That will put you in a much better position to switch your community over to a template-driven one in the future (templates become extensible in winter '15, and will only get better from there), and to take advantage of the extensive R&D work going into Community Cloud.

The Napili template (as well as plain old Chatter) uses FeedItem to store the first post of any conversation. This FeedItem will be associated with one of the Navigation Topics (and potentially other topics) by way of the TopicAssignment object. Comments to the original post will be tracked as FeedComment records. So let's say your community is run by Napili, and has the following Navigation Topics:
Routers (RecordId = 123456ABCDEF)
Access Points (RecordId = 2345678BCDEFG)

Then creating a post in Napili to the Routers section would create data that looked something like this:

FeedItem
ID: <auto-generated>
Title: <title of post>
Body: <body of post>
ParentId: <Id of posting User>
Type: QuestionPost

TopicAssignment
Id: <auto-generated>
EntityId: <id-of-your-post>
EntityType: FeedItem
NetworkId: <id-of-your-community>
TopicId: 123456ABCDEF

In this setup, navigation topics take the place of the CategoryGroups used by Chatter Answers. Since nav topics are connected by config to Data Categories, you can get to that as well.

Net-net: I strongly recommend you use the modern capabilities in FeedItem and FeedComment.