Jakob Anker
ServiceNow Employee
Options
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
‎01-02-2023
12:02 AM
As true as it is that data, in general, should never leave ServiceNow, if it can be avoided, it can be beneficial to export some data to Excel.
A rule of thumb: it is OK to extract data if the extraction is not degrading the workforce's ability to collaborate as a coherent unit through a single source of truth.
Extracting through Utility action
Extracting through RPA
Extracting through URL appendage
Extracting data through background script
This is only relevant if you need to extract large volumes of data across different tables with the potential for data transformation.
Building a script where you query and manipulate your data is needed. Then use gs.log() to print out the data rows you need. Use | as a column separator, and remember to add a log source (2nd parameter).
Script Example
gs.log('Number'+ '|' + 'State' + '|' + 'Brag'
var grIncident = new GlideRecord('incident');
grIncident.addActiveQuery();
grIncident.query();
gs.log(grIncident.number + '|' + grIncident.state + '|' + 'Look at me I am using background scripts to create spreadsheet data','spreadSheetRow');
}
Expected output
spreadSheetRow: Number|State|'Brag
spreadSheetRow: INC0000001|Open|Look at me I am using background scripts to create spreadsheet data
spreadSheetRow: INC0000002|Resolved|Look at me I am using background scripts to create spreadsheet data
spreadSheetRow: INC0000003|Open|Look at me I am using background scripts to create spreadsheet data
Data Cleanup
Use a program like notepade++ to remove any script tags (spreadSheetRow:)
Protip: you can use regular expressions to replace any lines containing any log statement contaminating your log output.
Example: /.*wordOrSentenceFoundInLine.*/g
Save the notepad once cleaned.
Moving to Excel
Open excel.
Go to data and add Text source.
Find your file and load the data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.