--- title: Retrieve Document Suggestions using Apex slug: '3317' canonical_url: https://docs.coveo.com/en/3317/ collection: coveo-for-salesforce source_format: adoc --- # Retrieve Document Suggestions using Apex [.version.c4sf.c4sf-edition.c4sf-enterprise] [Enterprise edition](https://docs.coveo.com/en/l2590456#salesforce) > **Available since** > > This feature was introduced in the August 2020 release of Coveo for Salesforce version [4.7](https://docs.coveo.com/en/3236#august-2020-release-v4-7). ## Prerequisite Ensure that you have your [Case Assist ID](https://docs.coveo.com/en/3315#retrieving-your-case-assist-id) on hand. ## Retrieving Document Suggestions . In Salesforce, access the Developer Console. . Instantiate the `CaseAssistApiClient` as follows: ```javascript String caseAssistId = '00000000-0000-0000-0000-000000000000'; Boolean debug = false; CoveoV2.CaseAssistApiClient client = CoveoV2.CaseAssistApiClient.getClient(caseAssistId, debug); ``` > **Note** > > The `debug` parameter is optional. > It indicates whether to include an execution report for debugging purposes. > The default value is `false`. . Invoke the `getDocumentSuggestions` method to retrieve the document suggestions. **Example** ```javascript Integer numberOfResults = 5; Map result = client.getDocumentSuggestions(new Map { 'clientId' => '04850f2-ee0d-47a9-aff5-39ee47f294f9', 'fields' => new Map { 'subject' => new Map { 'value' => 'My Case Subject' }, 'description' => new Map { 'value' => 'My Case Description' } }, 'context' => new Map { 'key' => 'value' } }, numberOfResults); ``` The `getDocumentSuggestions` method takes a `Map` as an input. . Specify values for the following arguments: .. `numberOfResults` is an optional parameter that specifies the maximum number of results to return. The default value is `5`. > **Note** > > The `numberOfResults` parameter is available in [Coveo for Salesforce v4.17](https://docs.coveo.com/en/3236#august-2021-release-v4-17) and later releases. .. [`clientID`](https://docs.coveo.com/en/masb0234/) identifies a specific instance of a browser client and provides insights into the [events](https://docs.coveo.com/en/260/) performed by the user. .. `fields` represents the [fields](https://docs.coveo.com/en/200/) of the current case that are considered meaningful for providing relevant documents. The `subject` and `description` fields are typically used to retrieve matching documents. > **Notes** > > - More fields can be added to better suit your use case. > > - The field values should be read from the current case and passed as a `Map` with a `value` key. . Optionally, provide [context](https://docs.coveo.com/en/1345/) information to leverage in the [query pipeline](https://docs.coveo.com/en/180/) (see [Manage ranking expression rules](https://docs.coveo.com/en/3375/) and [Manage query pipeline conditions](https://docs.coveo.com/en/1959/)). The result is a `Map`, which contains a list of document suggestions. **Example** ```javascript List documents = (List)result.get('documents'); ``` You can now retrieve and use document suggestions in your own application.