---
schema_version: "1"
id: ca3b378903f198e239cef80f88fe2e1d1265e32cb6aad6fb0e84a7e24a96bed4
title: Answers Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_classes_answers.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_answers.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: b259b6a520147833862f60ddc1cdb451e79f88b8aaf3ba23c40940414088a914
description: Represents zone answers.Returns a list of similar questions based on the title of the specified question.Sets the specified reply for the specified question as the best reply. Because a question can have multiple replies, setting the best reply helps users quickly identify the reply that contains the most helpful information.
---
# Answers Class

Represents zone answers.

## Namespace

[System](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_System.htm "The System namespace provides classes and methods for core Apex functionality.")

## 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

The following example finds questions in an internal zone that have similar titles as a new question:

public with sharing 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'  WITH USER\_MODE\];

   question.communityId = community.id;

   ID\[\] results = Answers.findSimilar(question);
   }
}

The following example marks a reply as the best reply:

ID questionId = \[SELECT Id FROM Question WHERE Title = 'Testing setBestReplyId' WITH USER\_MODE LIMIT 1\].Id;
ID replyID = \[SELECT Id FROM Reply WHERE QuestionId = :questionId WITH USER\_MODE LIMIT 1\].Id;
Answers.setBestReply(questionId,replyId);

## Answers Methods

The following are methods for Answers. All methods are static.

- **[findSimilar(yourQuestion)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_answers.htm#apex_System_Answers_findSimilar)**  
    Returns a list of similar questions based on the title of the specified question.
- **[setBestReply(questionId, replyId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_answers.htm#apex_System_Answers_setBestReply)**  
    Sets the specified reply for the specified question as the best reply. Because a question can have multiple replies, setting the best reply helps users quickly identify the reply that contains the most helpful information.

### findSimilar(yourQuestion)

Returns a list of similar questions based on the title of the specified question.

#### Signature

public static ID\[\] findSimilar(Question yourQuestion)

#### Parameters

- **yourQuestion**:
    
    Type: Question

#### Return Value

Type: [ID](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_id.htm#apex_methods_system_id "Contains methods for the ID primitive data type.")\[\]

#### Usage

Each findSimilar call counts against the SOSL statements governor limit allowed for the process.

### setBestReply(questionId, replyId)

Sets the specified reply for the specified question as the best reply. Because a question can have multiple replies, setting the best reply helps users quickly identify the reply that contains the most helpful information.

#### Signature

public static Void setBestReply(String questionId, String replyId)

#### Parameters

- **questionId**:
    
    Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")
- **replyId**:
    
    Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

#### Return Value

Type: Void