Utility Script to assist with manual updates to NDS Normalized Mapping, Name, and Company recordsIssue <!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } After implementing the Normalization Data Services (NDS) Guided Setup you may find inconsistencies with your existing records on the Company[core_company] table with various cases such as unexpected Normalized true/false flag, Normalized Mappings not present, incorrect Normalized Mappings, etc. requiring you to create or update the Normalized Mappings manually. Depending on each customer's unique data set this could be a handful of Company records or a few thousand Company records that you may want to update. This article has a custom Script Include attached with some helper functions that can be called from a background script to assist with these tasks and provides a few use cases with examples. Facts<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } The Attached Script Include NDSUtils needs to be imported to your instance for the background script examples in this article to work. When NDS is active: Company records that have Normalized Mapping record and the Normalized Name referenced on the mapping record is that company name, the Company record will be marked Normalized = true.Company records that have Normalized Mapping record and the Normalized Name referenced on the mapping record is NOT that company name, the Company record will be marked Normalized = false.Company records that do NOT have a Normalized Mapping record will marked Normalized = true. Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } All Releases Resolution<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } I. Import the attached Script Include NDSUtils 1. Download file sys_script_include_NDSUtils.xml attached to this KB. 2. Go to the Script Includes [sys_script_include] table on your instance. 3. Right Click the Column Headers at the top of the list. 4. Click Import XML. 5. Click Choose File and select sys_script_include_NDSUtils.xml. 6. Click Upload. II. Use Cases Use Case 1: List all of the Company records that are marked Normalized is True and do not have a Normalized Mapping record. 1. Go to the Company [core_company] table. 2. Open the bread crumb filter. 3. Choose field Sys ID. 4. Choose operator Is One Of. 5. Set below to the input field. javascript: new NDSUtils().getNormTrueWithNoCDN(); 6. Click Run - A list of all the Company records where Normalized is True and have no Normalized Mapping will be returned. ** On instances with a high number of such records the script can take a long time to return the list, thus it can also take an Encoded Query like "nameSTARTSWITHA" as input to shorten the list to all Normalized Company records starting with A that don't have a Normalized Mapping. javascript: new NDSUtils().getNormTrueWithNoCDN("nameSTARTSWITHA"); Use Case 2: Normalized Company and Normalized Name with no Normalized Mapping record linking the company to the normalized name. Example: You find four Company records below that are marked Normalized is true and should be mapped to Normalized Name "Canon" but aren't because there's no Normalized Mapping record with that Company Name linking it to the Normalized Name. CanonCanon Production PrintingCanon U.S.ACanon U.S.A. • One of these Company records will be the one that has a Normalized Mapping referencing the Normalized Name which matches that Company Name. • Open the records and check which one has related records under the Normalized Company Mappings and Normalized Company Names related lists. • The other Company records will have empty Normalized Company Mappings and Normalized Company Names related lists as they don't have a Normalized Mapping record. • Once you identify the Normalized Company Name record, go ahead and copy it's Sys Id as it'll be needed as an input for the script. Procedure 1. Identify the Normalized Name that you want the Normalized Mapping records to reference and copy it's Sys ID. 2. On the Company [core_company] table, query to filter only the records that you want to create Normalized Mappings to the Normalized Name for. 3. After the list has been filtered, right click on the breadcrumb filter and select Copy Query. Example of a copied query: "nameLIKEcanon^canonical=true" 4. Go to System Definition > Scripts - Background 5. Copy and paste the below script, adding the Normalized Name's Sys ID and the copied Encoded Query to the inputs before running the it. // 1. Add inputs here var normalizedNameSysId = ""; var encodedQuery = ""; // 2. Click Run Script // Do not edit below this line var ndsUtil = new NDSUtils(); var gr = new GlideRecord('core_company'); gr.addEncodedQuery(encodedQuery); gr.query(); while(gr.next()){ var companyName = gr.getValue("name"); ndsUtil.createMapping(companyName,normalizedNameSysId); } // Do not edit above this line 6. Click Run Script. 7. After the script completes the Normalized Mapping records will be created. 8. Finally you need to back to NDS Guided Setup and rerun steps Normalize CMDB (Configuration Items) and Normalize CMDB (Configuration Items) Models which will update the Company records to Normalized is False and update any CIs or Models referencing those company records with the normalized company they're now mapped to. Use Case 3: Create Normalized Mappings for Companies based on similarity with Names on existing Normalized Mapping records. // Set Inputs var encodedQuery = ""; var similarity = 80; var createMaps = false; // Please do not edit below this line var encQ = "canonical=true^" + encodedQuery; var gr = new GlideRecord('core_company'); var nds = new NDSUtils(); gr.addEncodedQuery(encQ); gr.setLimit(100); gr.query(); while(gr.next()){ var name = gr.getValue('name'); nds.possibleMatch(name,similarity,createMaps); } // Please do not edit above this line