Configure ServiceNow user story integration
Configure the ServiceNow instance user story integration to create stories in a production instance directly from finding records on a non-production instance.
Before you begin
- My SN Instances registration and authentication must be complete. See Register your instance.
- The User Story Table must exist on both the source and target instances before configuring field mappings.
Role required: Scan Engine Admin (sn_se.scan_engine_admin).
Procedure
ServiceNow integration script leading practices
TScript variables and leading practices for writing field mapping scripts in the ServiceNow instance user story integration.
Script variables
The field mapping script executes twice, once on the Source (Development) instance and once on the Destination (Production) instance. Use the isSource and isDestination variables to scope logic
appropriately for each context.
| Variable | Description |
|---|---|
isSource |
True when executing on the Source (Development) instance. |
isDestination |
True when executing on the Destination (Production) instance. |
payload |
User-defined variable for passing data between instances. |
grFinding |
GlideRecord of the finding. Available on the Source instance only. |
grTask |
GlideRecord of the task being created on the Destination instance. |
Leading practices
- Scope logic by instance context
- Always wrap Source-side logic in
if (isSource)and Destination-side logic inif (isDestination). The script runs in both contexts — accessinggrFindingon the Destination instance will fail because the finding record does not exist there. - Use payload to pass data across instances
- Populate
payloadon the Source instance with any values you need on the Destination. For example, setpayload.shortDescription = grFinding.short_descriptionon the Source, then readpayload.shortDescriptionon the Destination to set the task field. - Enable ES12 mode for modern JavaScript
- To use modern JavaScript syntax such as arrow functions, destructuring, or template literals, enable ECMAScript 2021 (ES12) mode in Scan Engine Properties before writing your mapping script.
- Validate field existence before mapping
- Confirm that all target fields in
grTaskexist on the User Story Table in the production instance. Mapping to a non-existent field fails silently and the value is discarded.