Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Finds values in fields that are pure sys_id's
//

var table = "cmn_location"; // Table to search in
var field = "name"; // Table field to search in

var grTable = new GlideRecord(table);
grTable.query();
var searchresults = "";
while (grTable.next()) {
var fieldvalue=grTable.getValue(field);
if(/^[a-f0-9]{32}$/.test(fieldvalue)) {
searchresults += fieldvalue + ",";
}
}
if( searchresults != "" ) {
gs.info("The following sys-ids were found in the " + table + "." + field + " field:");
gs.info(searchresults);
} else {
gs.info("No Sys-ID based values in " + table + "." + field);
}
9 changes: 9 additions & 0 deletions Background Scripts/Find sys_id named records/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Find sys_id named records

Use this background script to find records that contain a sys_id value in a specified field (other than the actual sys_id field)

This might for example have happened by accident during migration of data between two ServiceNow instances where referenced records on the target instance were accidentally created due to a Choice action=create setting on a Field Map.

How to use:

Change the "table" and "field" variables to the table and field name you want to search for sys_ids in