Retrieve Case Classifications using Apex
Retrieve Case Classifications using Apex
Prerequisite
You must have your Case Assist ID on hand. If you don’t, see Retrieving your Case Assist ID.
Retrieving Case Classifications
-
In Salesforce, access the Developer Console.
-
Instantiate the
CaseAssistApiClient
as follows:String caseAssistId = '00000000-0000-0000-0000-000000000000'; Boolean debug = false; CoveoV2.CaseAssistApiClient client = CoveoV2.CaseAssistApiClient.getClient(caseAssistId, debug);
NoteThe
debug
parameter is optional. It indicates whether to include an execution report for debugging purposes. The default value isfalse
. -
Invoke the
getCaseClassifications
method to retrieve the case classifications.ExampleMap<String, Object> classifications = client.getCaseClassifications(new Map<String, Object> { 'clientId' => '56f994be-320d-4c06-ab8e-f7c312d517ff', 'fields' => new Map<String, Object> { 'subject' => new Map<String, Object> {'value' => 'The case subject'}, 'description' => new Map<String, Object> {'value' => 'The case description'} } });
The
getCaseClassifications
method takes aMap<String, Object>
as an input. -
Specify values for the following arguments:
-
clientID
identifies a specific instance of a browser client and provides insights into the events performed by the user. -
fields
represents the fields of the current case that are considered meaningful for providing relevant case classifications. Thesubject
anddescription
fields are used to retrieve matching case classifications.Notes-
More fields can be added to better suit the use case.
-
The field values should be read from the current case and passed as a
Map<String, Object>
with avalue
key.
-
The result is a
Map<String, Object>
, which contains suggested values for the fields configured in the Case Classification configuration.ExampleMap<String, Object> fields = (Map<String, Object>)classifications.get('fields');
You’re now ready to retrieve and use case classifications in your own application.
-