|
additionalContext
|
Object
|
An optional parameter that you can use to pass any extra key–value information while you're performing a Lens service call. The examples show the key–value information that you can pass.- **Example**:
```
{IsFileUploadEnabled: true}
```
- **Example**: As part of the Excel mapping services, you can pass key-value information to:
- auto-map the column headers of an Excel file with ServiceNow table fields
- auto-map Excel values to ServiceNow drop-down values
- auto-map Excel values to referenced records in ServiceNow tables
For more information on the various key-values of the Excel mapping service, see [Key-values of the Excel auto-mapping services](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/ai-lens-action-service-api.md)
**Key-values of the Excel auto-mapping services**
- **Schema mapping** — Maps Excel column headers to ServiceNow table fields and identifies the field type of each mapped field. You can also use this option to map Excel column headers from a single sheet to multiple ServiceNow tables. Key-values for schema mapping are:
- `mappingStrategy`: Set to `'schema_mapping'`
- `rowContextSize`: Number of sample data rows to use for mapping context. Default: `10`.
- `randomizeRowOrder`: If `true`, Lens selects rows randomly from the Excel file. If `false`, Lens uses rows in order from the top.
- `sheetName`: Name of the Excel Sheet. If no name is specified, the first sheet is chosen by default.
- `headerRowNumber`: The row number from which the header with column names start with.
```
**Request example**: var response = new sn_app_lens_core.AILensActionService().invokeLens(
'b7fbd8694730c310dbc4964a516d431e',
['0c0b1c6d4730c310dbc4964a516d43f2'],
'', [], {},
true, {"mappingStrategy":"schema_mapping", sheetName: "Incident Data",headerRowNumber: 2,"rowContextSize":5,"randomizeRowOrder":false
}
);
gs.info("Lens Response : " + JSON.stringify(response));
**Response example**: {
"Owner": { "type": "string", "mappings": { "0.8": ["assigned_to", "parent", "epic"] } },
"Age": { "type": "integer", "mappings": { "0.8": ["story_points"] } },
"Status": { "type": "choice", "mappings": { "0.8": ["state", "priority"] }, "choiceValues": ["Retired", "On Boarding", "Working"] },
"Start Date": { "type": "glide_date", "mappings": { "1.0": ["expected_start"], "0.8": ["due_date"] } },
"End Date": { "type": "glide_date", "mappings": { "1.0": ["due_date"], "0.8": ["expected_start"] } },
"Project Assigned":{ "type": "string", "mappings": { "0.8": ["short_description", "task", "description"] } }
}
```
**Multi-table schema mapping**
Maps Excel column headers from a single sheet to multiple ServiceNow tables simultaneously. ServiceNow AI Lens identifies the relevant fields in each table for each Excel column header and maps the data accordingly.
**Request example**
```
var response = new sn_app_lens_core.AILensActionService().invokeLens(
"3290a3dc2b420310d666fe3db891bfb8",
["566997542b46c310a371f33ec891bfbc"],
"",
{},
{
'tableName': 'sn_ent_model,sn_ent_asset'
},
true,
{
"mappingStrategy": "schema_mapping",
"rowContextSize": 5,
"randomizeRowOrder": false,
"headerRowNumber": 2
}
);
gs.info("Overall Lens Response " + JSON.stringify(response));
var res = JSON.parse(response.lensResponse);
gs.info("Mapped Object" + JSON.stringify(res, null, ' '));
```
- **Choice mapping** — For fields identified as Choice type, maps the unique values from the Excel column to the valid choice values in the ServiceNow table field. Key-values for Choice mapping are:
- `mappingStrategy`: Set to `'choice_mapping'`.
- `columnConfigs`: An array of objects that specifies the ServiceNow choice field and the corresponding Excel column to map, including the field name, column header, and optionally the cell values to use instead of reading from the file.
```
**Request example**: {
mappingStrategy: 'choice_mapping',
SheetName:’Incident Data’,
SheetNameheaderRowNumber:2,
columnConfigs: [
{ field: 'priority', name: 'Priority' },
{ field: 'state', name: 'Ticket Status' }
]
}
**Response example**: [
{
"name": "Priority",
"field": "priority",
"mappings": [
{ "key": "High", "value": "1", "label": "1 - Critical", "score": 1.0 },
{ "key": "Medium", "value": "3", "label": "3 - Moderate", "score": 0.9 }
]
}
]
```
**Multi-column to single field choice mapping**
Maps multiple Excel column headers and their values to a single ServiceNow field. This is useful when related data from separate columns should be consolidated into one field.
**Request example**
```
var response = new sn_app_lens_core.AILensActionService().invokeLens(
"4b50a72c2b694710c18df2086e91bf84",
["e782e364936103105357f1cfb903d682"],
"",
{},
{},
true,
{
"mappingStrategy": "choice_mapping",
"columnConfigs": [
{ "field": "location", "name": "city" },
{ "field": "location", "name": "zip" },
{ "field": "location", "name": "state" }
]
}
);
gs.info("response " + JSON.stringify(response, null, ' '));
```
**Note:** Multi-column to single field mapping also works with Reference mapping.
- **Reference mapping** — Maps Excel cell values to the corresponding ServiceNow reference field records. Key-values for Reference mapping are:
- `mappingStrategy`: Set to `'reference_mapping'`.
- `columnConfigs`: Configuration for the specific column being mapped, including the source column name and the target reference table details.
```
**Request example**: var response = new sn_app_lens_core.AILensActionService().invokeLens(
'b7fbd8694730c310dbc4964a516d431e',
['0c0b1c6d4730c310dbc4964a516d43f2'],
'', [], {},
true, {
mappingStrategy: 'reference_mapping',
SheetName:’Incident Data’,
SheetNameheaderRowNumber:2,
columnConfigs: [{
field: 'assignment_group',
name: 'Assignment Group',
}]
}
);
**Response example**: [
{
"name": "Assignment Group",
"field": "assignment_group",
"mappings": [
{ "key": "IT Help Desk", "value": "abc123...", "label": "IT Help Desk", "score": 1.0 }
]
}
]
```
|