Example of scripts for Similarity Solution Definition

Smriti Rastogi
Kilo Guru

I have a similarity solution developed on incident table with fields - short description , configuration item & service offering.

How to call the similarity api ?

Should I pass the display value or sys id for these fields in the api?

Any links or coding examples would be helpful.

2 REPLIES 2

Lener Pacania1
ServiceNow Employee
ServiceNow Employee

Please see the ML API documentation for code examples for any of the PI models. In the documentation you will see we use sys_id of the record that you want to compare (see below).

var mlSolution = sn_ml.SimilaritySolutionStore.get('ml_incident_categorization');

// single GlideRecord input
var input = new GlideRecord("incident");
input.get("<sys_id>");

// configure optional parameters
var options = {};
options.top_n = 3;
options.apply_threshold = false;

var results = mlSolution.getVersion(1).predict(input, options);
// pretty print JSON results
gs.print(JSON.stringify(JSON.parse(results), null, 2));

HTH

 

Hi @Lener Pacania1 

I am also trying to use a Similarity Solution in a script. 

var mlSolution = sn_ml.SimilaritySolutionStore.get('ml_incident_categorization');

This code returns the "Similarity" type solutions, but not the newer "Workflow Similarity" solutions. How can I make use of those solutions?