Answers is a feature of the Community application that enables users to ask questions and have community members post replies. Community 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.
public class FindSimilarQuestionController { public static void test() { // Instantiate a new question Question question = new Question (); // Specify a title for the new question question.title = 'How much vacation time do full-time employees get?'; // Specify the communityID (INTERNAL_COMMUNITY) in which to find similar questions. Community community = [ SELECT Id FROM Community WHERE Name = 'INTERNAL_COMMUNITY' ]; question.communityId = community.id; ID[] results = Answers.findSimilar(question); } }
ID questionId = [SELECT Id FROM Question WHERE Title = 'Testing setBestReplyId' LIMIT 1].Id; ID replyID = [SELECT Id FROM Reply WHERE QuestionId = :questionId LIMIT 1].Id; Answers.setBestReply(questionId,replyId);
The following are methods for Answers. All methods are static.
public static ID[] findSimilar(Question yourQuestion)
Type: ID[]
Each findSimilar call counts against the SOSL statements governor limit allowed for the process.
public static Void setBestReply(String questionId, String replyId)
Type: Void