Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Answers Class
Namespace
Usage
Answers is a feature that enables users to ask questions and have zone members post replies. Members can then vote on the helpfulness of each reply, and the person who asked the question can mark one reply as the best answer.
For more information on answers, see “Answers Overview” in the Salesforce online help.
Example
1public class FindSimilarQuestionController {
2
3 public static void test() {
4 // Instantiate a new question
5 Question question = new Question ();
6
7 // Specify a title for the new question
8 question.title = 'How much vacation time do full-time employees get?';
9
10 // Specify the communityID (INTERNAL_COMMUNITY) in which to find similar questions.
11 Community community = [ SELECT Id FROM Community WHERE Name = 'INTERNAL_COMMUNITY' ];
12
13 question.communityId = community.id;
14
15 ID[] results = Answers.findSimilar(question);
16 }
17}1ID questionId = [SELECT Id FROM Question WHERE Title = 'Testing setBestReplyId' LIMIT 1].Id;
2ID replyID = [SELECT Id FROM Reply WHERE QuestionId = :questionId LIMIT 1].Id;
3Answers.setBestReply(questionId,replyId);Answers Methods
The following are methods for Answers. All methods are static.
findSimilar(yourQuestion)
Signature
public static ID[] findSimilar(Question yourQuestion)
Parameters
-
yourQuestion:
Type: Question
Return Value
Type: ID[]
Usage
Each findSimilar call counts against the SOSL statements governor limit allowed for the process.
setBestReply(questionId, replyId)
Signature
public static Void setBestReply(String questionId, String replyId)
Return Value
Type: Void