RegressionSolution - Global

concept brazil Updated Sep 10, 2026 9 min read RegressionSolutionAPI.md
Raw file servicenow.com

The RegressionSolution API is a scriptable object used in Predictive Intelligence stores.

This API requires the Predictive Intelligence plugin (com.glide.platform_ml) and is provided within the sn_ml namespace.

The solution setup-to-training flow is as follows:

  1. Create a dataset using the DatasetDefinition API.
  2. Optional. Build an encoder using the Encoder API.
  3. Use the constructor to create a regression solution object.
  4. Add the solution object to the regression solution store using the RegressionSolutionStore - add() method.
  5. Train the solution using the submitTrainingJob() method. This creates a version of the object that you can manage using the RegressionSolutionVersion API.
  6. Get predictions using the RegressionSolutionVersion – predict() method.

Note: This API runs with full privileges before the Vancouver Patch 7 Hotfix 2b and Washington DC Patch 7 releases. With later releases, grant access using ACLs. For more information see Query ACLs.

For usage guidelines, refer to Using ML APIs.

Parent Topic:Server API reference

RegressionSolution - RegressionSolution(Object config)

Creates a regression solution.

Name

Type

Description

config

Object

JavaScript object containing configuration properties of thesolution.``` { "algorithmConfig": {Object}, "dataset": {Object}, "domainName": "String", "encoder": {Object}, "inputFieldNames": [Array], "label": "String", "minRowCount": "String", "predictedFieldName": "String", "predictedInterval": [Array], "processingLanguage": "String", "stopwords": [Array], "trainingFrequency": "String" }

Text
</td></tr><tr><td>
config.dataset
</td><td>
Object
</td><td>
[DatasetDefinition](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/DatasetDefinitionAPI.md) name.
</td></tr><tr><td>
config.domainName
</td><td>
String
</td><td>
Optional. Domain name associated with this dataset. Default: Current domain, for example, `"global"`.
</td></tr><tr><td>
config.encoder
</td><td>
Object
</td><td>
Optional. Trained encoder object to assign to this solution. See [Encoder - Encoder\(Object config\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/EncoderAPI.md).
</td></tr><tr><td>
config.inputFieldNames
</td><td>
Array
</td><td>
List of input field names as strings. The model uses these fields used to make predictions.
</td></tr><tr><td>
config.label
</td><td>
String
</td><td>
Identifies the prediction task.
</td></tr><tr><td>
config.minRowCount
</td><td>
String
</td><td>
Optional. Minimum number of records required in the dataset for training.Default: 10000
</td></tr><tr><td>
config.predictedFieldName
</td><td>
String
</td><td>
Mandatory unless setting **predictedInterval**. Identifies a field to be trained for predictability.
</td></tr><tr><td>
config.predictedInterval
</td><td>
Array
</td><td>
Mandatory unless setting **predictedFieldName**. Sets a range of fields to train your solution for confidence. Supports providing 2 non-numeric date fields. For example, `'predictedInterval': ['sys_updated_on', 'sys_created_on']`.
</td></tr><tr><td>
config.processingLanguage
</td><td>
String
</td><td>
Optional. Processing language in two-letter ISO 639-1 language code format. Default: "en"
</td></tr><tr><td>
config.stopwords
</td><td>
Array
</td><td>
Optional. Preset list of strings that the system automatically generates based on the **language** property setting. For details, see [Create a custom stopwords list](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/intelligent-experiences/create-custom-stopwords-list.md). Default: English Stopwords
</td></tr><tr><td>
config.trainingFrequency
</td><td>
String
</td><td>
The frequency to retrain the model. Possible values:
-   every\_30\_days-   every\_60\_days-   every\_90\_days-   every\_120\_days-   every\_180\_days-   run\_once
Default: run\_once
</td></tr></tbody></table>The following example shows how to create an object and add it to the RegressionSolution store.

var myNewData = new sn_ml.DatasetDefinition( { 'tableName' : 'incident', 'fieldNames' : ['category', 'short_description', 'priority'], 'fieldDetails' : [ { 'name' : 'category', 'type' : 'nominal' }, { 'name' : 'short_description', 'type' : 'text' }], 'encodedQuery' : 'activeANYTHING' });

var mySimSolution = new sn_ml.SimilaritySolution({ 'label': "my solution definition", 'dataset' : myNewData, 'predictedFieldName' : 'category', 'inputFieldNames': ['short_description'] });

var mySimilarityName = sn_ml.SimilaritySolutionStore.add(mySimSolution);

Text
The following example shows how to create an object to train using the **predictedInterval** property.

var myIncidentData = new sn_ml.DatasetDefinition({ 'tableName' : 'incident', 'fieldNames' : ['short_description', 'sys_updated_on','sys_created_on'], 'encodedQuery' : 'activeANYTHING' });

var mySolution = new sn_ml.RegressionSolution({ 'label': 'reg assinGroup', 'dataset' : myIncidentData, 'predictedInterval': ['sys_updated_on', 'sys_created_on'], 'inputFieldNames': ['short_description'] });

var my_unique_name = sn_ml.RegressionSolutionStore.add(mySolution)

Text
## RegressionSolution - cancelTrainingJob\(\)
Cancels a job for a solution object that has been submitted for training.
|Name|Type|Description||----|----|-----------||None| | |
|Type|Description||----|-----------||None| |
The following example shows how to cancel an existing training job.

var mySolution = sn_ml.RegressionSolutionStore.get('ml_sn_global_global_regression');

mySolution.cancelTrainingJob();

Text
## RegressionSolution - getActiveVersion\(\)
Gets the active RegressionSolutionVersion object.
|Name|Type|Description||----|----|-----------||None| | |
|Type|Description||----|-----------||Object|Active [RegressionSolutionVersion](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/RegressionSolutionVersionAPI.md) object.|
The following example shows how to get an active RegressionSolution version from the store and return its training status.

var mlSolution = sn_ml.RegressionSolutionStore.get('ml_x_snc_global_global_regression');

gs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getStatus()), null, 2));

Text
Output:

{ "state": "solution_complete", "percentComplete": "100", "hasJobEnded": "true" }

Text
## RegressionSolution - getAllVersions\(\)
Gets all versions of a RegressionSolution object.
|Name|Type|Description||----|----|-----------||None| | |
|Type|Description||----|-----------||Array|Existing versions of a solution object. See also [RegressionSolutionVersion](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/RegressionSolutionVersionAPI.md) API.|
The following example shows how to get all RegressionSolution version objects and call the getVersionNumber\(\) and getStatus\(\) solution version methods on them.

var mlSolution = sn_ml.RegressionSolutionStore.get('ml_x_snc_global_global_regression');

var mlSolutionVersions = mlSolution.getAllVersions();

for (i = 0; i < mlSolutionVersions.length; i++) { gs.print("Version " + mlSolutionVersions[i].getVersionNumber() + " Status: " + mlSolutionVersions[i].getStatus() +"\n"); };

Text
Output:

Version 3 Status: {"state":"solution_complete","percentComplete":"100","hasJobEnded":"true"}

Version 2 Status: {"state":"solution_complete","percentComplete":"100","hasJobEnded":"true"}

Version 1 Status: {"state":"solution_cancelled","percentComplete":"0","hasJobEnded":"true"}

Text
## RegressionSolution - getLatestVersion\(\)
Gets the latest version of a solution.
|Name|Type|Description||----|----|-----------||None| | |
|Type|Description||----|-----------||Object|[RegressionSolutionVersion](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/RegressionSolutionVersionAPI.md) object corresponding to the latest version of a [RegressionSolution\(\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/RegressionSolutionAPI.md).|
The following example shows how to get the latest version of a solution and return its training status.

var mlSolution = sn_ml.RegressionSolutionStore.get('ml_x_snc_global_global_regression');

gs.print(JSON.stringify(JSON.parse(mlSolution.getLatestVersion().getStatus()), null, 2));

Text
Output:

{ "state": "solution_complete", "percentComplete": "100", "hasJobEnded": "true" }

Text
## RegressionSolution - getName\(\)
Gets the name of the object to use for interaction with the store.
|Name|Type|Description||----|----|-----------||None| | |
|Type|Description||----|-----------||String|Name of the solution object.|
The following example shows how to update RegressionSolution dataset information and print the name of the object.

// Update solution var myIncidentData = new sn_ml.DatasetDefinition({ 'tableName' : 'incident', 'fieldNames' : ['category', 'short_description', 'priority'], 'encodedQuery' : 'activeANYTHING' });

var eligibleFields = JSON.parse(myIncidentData.getEligibleFields('regression'));

var myRegression = new sn_ml.RegressionSolution({ 'label': "my regression solution", 'dataset' : myIncidentData, 'inputFieldNames': eligibleFields['eligibleInputFieldNames'], 'predictedFieldName': 'category' });

// update solution sn_ml.RegressionSolutionStore.update('ml_x_snc_global_global_my_solution_definition_4', myRegression);

// print solution name gs.print('Solution Name: '+myRegression.getName());

Text
Output:

Solution Name: ml_x_snc_global_global_my_solution_definition_4

Text
## RegressionSolution - getProperties\(\)
Gets solution object properties.
|Name|Type|Description||----|----|-----------||None| | |
<table id="table_qps_43z_llb" class="returns"><thead><tr><th>
Type
</th><th>
Description
</th></tr></thead><tbody><tr><td>
Object
</td><td>
Contents of the Dataset and [RegressionSolution\(\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/RegressionSolutionAPI.md) object details in the [RegressionSolutionStore](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/RegressionSolutionStoreAPI.md).```{  "datasetProperties": {Object},  "domainName": "String",  "encoder": {Object},  "inputFieldNames": [Array],  "label": "String",  "name": "String",  "predictedFieldName": "String",  "predictedInterval": [Array],  "processingLanguage": "String",  "scope": "String",  "stopwords": [Array],  "trainingFrequency": "String"}

<Object>.datasetProperties

Lists the properties of the DatasetDefinition() object associated with the solution.

JavaScript
{ "encodedQuery": "String", "fieldDetails": [Array], "fieldNames": [Array], "tableName": "String"}

Data type: Object.

<Object>.datasetProperties.tableName

Name of the table for the dataset. For example, "tableName" : "Incident". Data type: String.

<Object>.datasetProperties.fieldNames

List of field names from the specified table as strings. For example, "fieldNames" : ["short_description", "priority"]. Data type: Array.

<Object>.datasetProperties.fieldNames.fieldDetails

List of JavaScript objects that specify field properties. ``` [ { "name": "String", "type": "String" } ]

Text
 Data type: Array.
</td></tr><tr><td>
&lt;Object&gt;.datasetProperties.fieldNames.fieldDetails.&lt;object&gt;.name
</td><td>
Name of the field defining the type of information to restrict this dataset to. Data type: String.
</td></tr><tr><td>
&lt;Object&gt;.datasetProperties.fieldDetails.&lt;object&gt;.type
</td><td>
Machine-learning field type. Data type: String.
</td></tr><tr><td>
&lt;Object&gt;.datasetProperties.fieldDetails.encodedQuery
</td><td>
Encoded query string in the standard platform format. See [Encoded query strings](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/platform-user-interface/c_EncodedQueryStrings.md).Data type: String.
</td></tr><tr><td>
&lt;Object&gt;.domainName
</td><td>
Domain name associated with this dataset. See [Domain separation and Predictive Intelligence](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/intelligent-experiences/domain-separation-predictive-intelligence.md).Type: String
</td></tr><tr><td>
&lt;Object&gt;.encoder
</td><td>
Encoder object assigned to this solution. See [Encoder - Encoder\(Object config\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/EncoderAPI.md).Data type: Object.
</td></tr><tr><td>
&lt;Object&gt;.inputFieldNames
</td><td>
List of input field names as strings. The model uses these fields used to make predictions. Data type: String.
</td></tr><tr><td>
&lt;Object&gt;.label
</td><td>
Identifies the prediction task. ```{  "label": "my first prediction"}

Data type: String.

<Object>.name

System-assigned name. Data type: String.

<Object>.predictedFieldName

Identifies a field to be trained for predictability. Data type: String.

<Object>.predictedInterval

Range of values specifying the prediction confidence level.Data type: Array

<Object>.processingLanguage

Processing language in two-letter ISO 639-1 language code format. Data type: String.

<Object>.scope

Object scope. Currently the only valid value is global.Data type: String

<Object>.stopwords

Optional. Preset list of strings that the system automatically generates based on the language property setting. For details, see Create a custom stopwords list. Data type: Array.

<Object>.trainingFrequency

The frequency to retrain the model. Possible values:

  • every_30_days
  • every_60_days
  • every_90_days
  • every_120_days
  • every_180_days
  • run_once

Default: run_once

Data type: String.

The following example gets properties of a solution object in the store.
JavaScript
var mySolution = sn_ml.RegressionSolutionStore.get('ml_sn_global_global_regression_solution');
gs.print(JSON.stringify(JSON.parse(mySolution.getProperties()), null, 2));

Output:

CSS
*** Script: {  "datasetProperties": {    "tableName": "cloudinfratext",    "fieldNames": [      "short_description",      "sourcedc",      "targetdc",      "dbsize",      "duration"    ]  },  "domainName": "global",  "encoderProperties": {    "datasetsProperties": [],    "name": "wc_regression"  },  "inputFieldNames": [    "short_description",    "sourcedc",    "targetdc",    "dbsize"  ],  "label": "Regression Test for DB Restore",  "name": "ml_x_snc_global_global_regression",  "predictedFieldName": "duration",  "processingLanguage": "en",  "scope": "global",  "stopwords": [    "Default English Stopwords"  ],  "trainingFrequency": "every_30_days"}

RegressionSolution - getVersion(String version)

Gets a solution by provided version number.

Name Type Description
version String Existing version number of a solution.
Type Description
Object Specified version of the RegressionSolution() object on which you can call RegressionSolutionVersion API methods.

The following example shows how to get the training status of a solution by version number.

JavaScript
var mlSolution = sn_ml.RegressionSolutionStore.get('ml_x_snc_global_global_regression');
gs.print(JSON.stringify(JSON.parse(mlSolution.getVersion('1').getStatus()), null, 2));

Output:

JSON
{  "state": "solution_complete",  "percentComplete": "100",  "hasJobEnded": "true"}

RegressionSolution - setActiveVersion(String version)

Activates a specified version of a solution in the store.

Name

Type

Description

version

String

Name of the RegressionSolution() object version to activate.Activating this version deactivates any other version.

|Type|Description| |----|-----------| |None| |

The following example shows how to activate a solution version in the store.

JavaScript
sn_ml.RegressionSolution.setActiveVersion("ml_incident_categorization");

RegressionSolution - submitTrainingJob()

Submits a training job.

Note: Before running this method, you must first add a solution to the store using the RegressionSolutionStore - add() method.

Name Type Description
None
Type Description
Object RegressionSolutionVersion object corresponding to the RegressionSolution being trained.

The following example shows how to create a dataset, apply it to a solution, add the solution to a store, and submit the training job.

JavaScript
// Create a dataset var myData = new sn_ml.DatasetDefinition({
  'tableName' : 'incident',  'fieldNames' : ['assignment_group', 'short_description', 'description'],  'encodedQuery' : 'activeANYTHING'
});
// Create a solution var mySolution = new sn_ml.RegressionSolution({
  'label': "my solution definition",  'dataset' : myData,  'predictedFieldName' : 'assignment_group',  'inputFieldNames':['short_description']
});
// Add the solution to the store to later be able to retrieve it.var my_unique_name = sn_ml.RegressionSolutionStore.add(mySolution);
// Train the solution - this is a long running job var myRegressionVersion = mySolution.submitTrainingJob();
Search documentation
Search document titles and file paths on the brazil branch