Show Sofi suggestions on a form
Add a UI event that starts Sofi on a table's form, so agents see classification, knowledge and action suggestions as they type.
Add Sofi to a form when a table has a classifier but its form shows no Sofi suggestions. The shipped tables, such as Incident, Change and HR case, already have this UI event. This page is for administrators who write UI events.
Before you begin
- You need the
administratorrole and the rights to edit UI events. - A classifier must exist for the table. See Create a classifier.
- Note the classifier names to call: the classification classifier, and if you want them the knowledge and action classifiers, such as
Knowledgeand anActionResult…classifier.
Steps
-
Go to Administration → Business Logic → UI event. Open a shipped event such as “Incident - Enable sofi on form load” to use as a model.
-
Select New. Enter a Name such as “My table - Enable sofi on form load”, set Table to your table, Event type to the form event type and Event name to
onLoad. -
Enter the script. It registers Sofi on the main form view and runs the classifiers whenever the trigger field changes.
if (formContext == "detail.main") { include(["SofiClient", "SofiActivityLogger"], function (SofiClient, SofiActivityLogger) { var triggerField = "ShortDescription"; function runSofi(searchText, options) { if (!searchText) { activityLogger.clearLogActivity(); } client.classify(searchText, "MyClassifier", options); client.knowledgeSearch(searchText, "Knowledge"); } let client = SofiClient.registerFormInstance(_formInstance, current); let activityLogger = SofiActivityLogger.setup(client, _formInstance, current, "WorkJournal", triggerField); client.onFieldEvent(triggerField, "*", function (event) { activityLogger.setTriggerFieldChanged(true); runSofi(event.newValue); }); setTimeout(() => { if (current.getField(triggerField).hasValue()) { runSofi(current.getField(triggerField).getValue(), { force: true }); } }, 1000); }); } -
Replace
MyClassifierwith your classifier’s name, andShortDescriptionwith the field the classifier reads. To rank intelligent actions too, addclient.actionSearch(searchText, "<action classifier>", options);and theclient.onExecuteIntelligentActionhandler from the shipped event. -
Select Active and save.
Result
When an agent types in the trigger field, the Sofi panel shows suggestions in its Sofi Smart Classification tab. Knowledge appears in Sofi Smart Search. Sofi notes what it found in the work journal. The classifier’s UI context decides whether values are filled in automatically.