AttachToCaseController Apex class
AttachToCaseController Apex class
The AttachToCaseController
Apex class provides methods to attach search results to Salesforce Cases and other records, detach them, and retrieve lists of attached results.
This class supports both Coveo search results and Salesforce Knowledge Articles.
The typical use case is to create a custom Insight Panel result action that allows users to attach search results to Cases or other records directly from a custom Coveo Quantic Insight Panel.
Methods
AttachToCase
@AuraEnabled
global static string AuraAttachToCase(string result)
Attaches a search result to a Salesforce record.
Parameters
-
result
(String
): StringifiedResultToAttachArg
. The result object to attach.
Returns
String
: JSON-serialized AttachToCaseResponse
. Response indicating success or failure.
Functionality
-
Creates or updates the appropriate attached result records.
-
For Knowledge Articles, also creates a
CaseArticle
relationship (Cases only).
DetachFromCase
@AuraEnabled
global static string AuraDetachFromCase(string uriHash, string sfkbid, string caseId)
Detaches a previously attached search result from a Salesforce record.
Parameters
-
uriHash
(String
): Permanent ID [or URI hash (deprecated)] of the result to detach. -
sfkbid
(String
): Knowledge Article ID (for Knowledge Article detachment). -
caseId
(String
): ID of the record to detach from.
Returns
String
: JSON-serialized AttachToCaseResponse
. Response indicating success or failure.
Functionality
-
Removes the corresponding attached result records.
-
For Cases, also removes the
CaseArticle
relationship if applicable.
getAttachedResults
@AuraEnabled
global static String getAttachedResults(Id caseId)
Retrieves all results attached to a specific record.
Parameters
-
caseId
(Id
): ID of the record to retrieve attached results for.
Returns
String
: JSON-serialized AttachedResultsDetailed
object.
Functionality
-
Queries both Coveo attached results and Knowledge Articles.
-
Returns detailed information for each attached result.
Classes and data types
ResultToAttachArg
Represents a search result to be attached to a record.
Property | Type | Description |
---|---|---|
|
|
ID of the Salesforce record to attach the result to |
|
|
(Optional) ID of a Salesforce Knowledge Article |
|
|
(Optional) Language of the Knowledge Article |
|
|
(Optional) Version number of the Knowledge Article |
|
|
(Optional) Publication status of the Knowledge Article |
|
|
Unique hash identifier for the result URL |
|
|
Permanent identifier for the result |
|
|
URL of the search result |
|
|
Source system or content repository |
|
|
Title of the search result |
|
|
Display name for the attached result |
|
|
Custom field values to store with the result |
AttachToCaseResponse
Response object for attach and detach operations.
Property | Type | Description |
---|---|---|
|
|
Whether the operation completed successfully |
|
|
Success message or error details |
AttachedResults
Response object for retrieving attached results lists.
Property | Type | Description |
---|---|---|
|
|
Whether the retrieval operation completed successfully |
|
|
Success message or error details |
|
|
List of attached result identifiers |
AttachedResultsDetailed
Response object for retrieving detailed attached results information.
Property | Type | Description |
---|---|---|
|
|
Whether the retrieval operation completed successfully |
|
|
Success message or error details |
|
|
List of detailed attached result objects |