SAMP: Duplicate SAM Value Builder Task Numbers on samp_sp_vb_task TableIssue <!-- /*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: ; } } .kb-wrapper { font-family: Lato, sans-serif; font-size: 12pt; line-height: 1.7; max-width: 100%; } .kb-wrapper p { font-family: Lato, sans-serif; font-size: 12pt; margin: 0 0 10px 0; } .kb-wrapper code { background: #e6f0f5; color: #032D42; border: 1px solid #b8cfd8; border-radius: 3px; padding: 1px 5px; font-size: 11pt; } Duplicate Number values exist on the SAM Value Builder Task (samp_sp_vb_task) table, causing records to be flagged during ServiceNow Health Scans. Symptoms<!-- /*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: ; } } .kb-wrapper { font-family: Lato, sans-serif; font-size: 12pt; line-height: 1.7; max-width: 100%; } .kb-wrapper ul { font-family: Lato, sans-serif; font-size: 12pt; margin: 0 0 10px 0; padding-left: 20px; } .kb-wrapper li { margin-bottom: 6px; } .kb-wrapper code { background: #e6f0f5; color: #032D42; border: 1px solid #b8cfd8; border-radius: 3px; padding: 1px 5px; font-size: 11pt; } Two or more SAM Value Builder Task records share the same Number field value (e.g., SVB0001014, SVB0001015).ServiceNow Health Scan results flag duplicate record numbers on the samp_sp_vb_task table.The duplicate records have different Sys IDs but identical Number and Name values. 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: ; } } .kb-wrapper { font-family: Lato, sans-serif; font-size: 12pt; line-height: 1.7; max-width: 100%; } .kb-wrapper p { font-family: Lato, sans-serif; font-size: 12pt; margin: 0 0 10px 0; } .kb-wrapper ul { font-family: Lato, sans-serif; font-size: 12pt; margin: 0 0 10px 0; padding-left: 20px; } .kb-wrapper li { margin-bottom: 6px; } .kb-wrapper code { background: #e6f0f5; color: #032D42; border: 1px solid #b8cfd8; border-radius: 3px; padding: 1px 5px; font-size: 11pt; } .kb-wrapper table { border-collapse: collapse; width: 100%; margin: 10px 0 16px 0; font-size: 12pt; } .kb-wrapper th { background: #032D42; color: #ffffff; padding: 8px 10px; text-align: left; font-weight: bold; } .kb-wrapper td { padding: 7px 10px; border-bottom: 1px solid #cde0e8; } .kb-wrapper tr:nth-child(even) td { background: #e8fce4; } The original (non-duplicate) records are installed via plugin XML with hardcoded Number values and Sys IDs. These records are consistent across all instances: NumberNameSys IDSVB0001014Complete Microsoft SQL Server License Management Guided Setup82114d270f4d3110ebd9579ac4767ef7SVB0001015Complete Microsoft Windows Server License Management Guided Setupfb744de70f4d3110ebd9579ac4767e77 The duplicate records are created by an update script during a plugin install or upgrade. These records share the same Number and Name across instances but have different Sys IDs per instance: NumberNameSys IDSVB0001014Cisco Webex MeetingsInstance-specificSVB0001015RoadmunkInstance-specific The duplicates do not impact the creation or numbering of new SAM Value Builder Tasks. UI Actions on samp_usage_under_management, samp_sp_apps_and_plugins, and samp_sp_publisher_pack_utilization correctly assign the next sequential Number when creating new tasks. 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 Cause<!-- /*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: ; } } .kb-wrapper { font-family: Lato, sans-serif; font-size: 12pt; line-height: 1.7; max-width: 100%; } .kb-wrapper p { font-family: Lato, sans-serif; font-size: 12pt; margin: 0 0 10px 0; } .kb-wrapper code { background: #e6f0f5; color: #032D42; border: 1px solid #b8cfd8; border-radius: 3px; padding: 1px 5px; font-size: 11pt; } During a SAM plugin install or upgrade, an update script creates additional SAM Value Builder Task records (for Cisco Webex Meetings and Roadmunk) using hardcoded Number values that conflict with existing records already installed via the plugin XML. Because the original records have their Numbers baked into the XML rather than assigned by the sys_number_counter sequencer, the update script inadvertently reuses the same Number values, resulting in duplicates. 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: ; } } .kb-wrapper { font-family: Lato, sans-serif; font-size: 12pt; line-height: 1.7; max-width: 100%; } .kb-wrapper p { font-family: Lato, sans-serif; font-size: 12pt; margin: 0 0 10px 0; } .kb-wrapper ul { font-family: Lato, sans-serif; font-size: 12pt; margin: 0 0 10px 0; padding-left: 20px; } .kb-wrapper li { margin-bottom: 6px; } .kb-wrapper h3 { font-family: Lato, sans-serif; font-size: 12pt; font-weight: bold; color: #032D42; margin: 16px 0 6px 0; } .kb-wrapper code { background: #e6f0f5; color: #032D42; border: 1px solid #b8cfd8; border-radius: 3px; padding: 1px 5px; font-size: 11pt; } .kb-wrapper .callout-info { background: #e6f4ff; border-left: 4px solid #52B8FF; padding: 10px 14px; margin: 14px 0; border-radius: 2px; } .kb-wrapper .callout-info p { margin: 0; } .kb-wrapper textarea { width: 100%; min-height: 420px; font-family: monospace; font-size: 10pt; background: #f4f8fa; color: #032D42; border: 1px solid #b8cfd8; border-radius: 4px; padding: 10px; resize: vertical; box-sizing: border-box; } .kb-wrapper .steps { list-style: none; padding-left: 0; counter-reset: step-counter; } .kb-wrapper .steps > li { counter-increment: step-counter; display: block; padding-left: 38px; position: relative; margin-bottom: 10px; } .kb-wrapper .steps > li::before { content: counter(step-counter); position: absolute; left: 0; top: 2px; display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: #032D42; color: #63DF4E; font-weight: bold; font-size: 11pt; } Run the background script below to renumber the duplicate records and update the sys_number_counter sequencer so that future records continue in the correct sequence. Before You Begin The script includes a dry-run mode enabled by default (dryRun = true). Run it in dry-run mode first to review the planned changes in the system logs before committing.Validate the output in the system logs to confirm the correct records are identified for renumbering.Once satisfied, set dryRun = false and run the script again to apply the changes. Steps Navigate to System Definition > Scripts - Background.Paste the script below into the editor.Run the script with dryRun = true (default) and review the output in the system logs.Confirm the correct duplicate records are identified and the proposed new Numbers are appropriate.Set dryRun = false and run the script again to apply the changes.Verify the duplicates have been renumbered by checking the samp_sp_vb_task table.Re-run the Health Scan to confirm the duplicate number findings are resolved. Background Script // =========================================================================== // Fix Duplicate Numbers on samp_sp_vb_task // =========================================================================== // PURPOSE: Finds duplicate Number values, renumbers the newer duplicates // with the next available numbers, and updates the sys_number_counter // sequencer so future records continue in sequence. // // TABLE: samp_sp_vb_task (SAM Value Builder Tasks) // PREFIX: SBV // // ⚠️ DRY RUN MODE: Set dryRun = false to commit changes. // =========================================================================== var dryRun = true; // Set to false to apply changes var duplicateMap = {}; var ga = new GlideAggregate('samp_sp_vb_task'); ga.addAggregate('COUNT', 'number'); ga.addHaving('COUNT', 'number', '>', 1); ga.query(); while (ga.next()) { var dupNumber = ga.getValue('number'); var records = []; var gr = new GlideRecord('samp_sp_vb_task'); gr.addQuery('number', dupNumber); gr.orderBy('sys_created_on'); gr.query(); while (gr.next()) { records.push({ sys_id: gr.getUniqueValue(), number: gr.getValue('number'), created_on: gr.getValue('sys_created_on') }); } duplicateMap[dupNumber] = records; } var toRenumber = []; for (var num in duplicateMap) { var set = duplicateMap[num]; gs.info('Duplicate Number: ' + num + ' — ' + set.length + ' records found'); gs.info(' Keeping oldest: sys_id=' + set[0].sys_id + ', created_on=' + set[0].created_on); for (var i = 1; i < set.length; i++) { gs.info(' Will renumber: sys_id=' + set[i].sys_id + ', created_on=' + set[i].created_on); toRenumber.push(set[i].sys_id); } } if (toRenumber.length === 0) { gs.info('No duplicate Numbers found. No changes needed.'); } else { gs.info('Total records to renumber: ' + toRenumber.length); var grMax = new GlideRecord('samp_sp_vb_task'); grMax.orderByDesc('number'); grMax.setLimit(1); grMax.query(); var highestNumber = 0; if (grMax.next()) { var currentMax = grMax.getValue('number'); highestNumber = parseInt(currentMax.replace(/[^0-9]/g, ''), 10); gs.info('Current highest Number on table: ' + currentMax + ' (numeric: ' + highestNumber + ')'); } var sampleNumber = grMax.getValue('number'); var numericPart = sampleNumber.replace(/^[A-Za-z]+/, ''); var padLength = numericPart.length; var nextNumber = highestNumber; for (var j = 0; j < toRenumber.length; j++) { nextNumber++; var paddedNum = String(nextNumber); while (paddedNum.length < padLength) { paddedNum = '0' + paddedNum; } var newNumber = 'SBV' + paddedNum; var grUpdate = new GlideRecord('samp_sp_vb_task'); if (grUpdate.get(toRenumber[j])) { var oldNumber = grUpdate.getValue('number'); if (dryRun) { gs.info('[DRY RUN] Would update sys_id=' + toRenumber[j] + ': ' + oldNumber + ' → ' + newNumber); } else { grUpdate.setValue('number', newNumber); grUpdate.setWorkflow(false); grUpdate.autoSysFields(false); grUpdate.update(); gs.info('Updated sys_id=' + toRenumber[j] + ': ' + oldNumber + ' → ' + newNumber); } } } var grSeq = new GlideRecord('sys_number_counter'); grSeq.addQuery('table', 'samp_sp_vb_task'); grSeq.query(); if (grSeq.next()) { var oldSeqNumber = grSeq.getValue('number'); if (dryRun) { gs.info('[DRY RUN] Would update sys_number_counter sequencer from ' + oldSeqNumber + ' → ' + nextNumber); } else { grSeq.setValue('number', nextNumber); grSeq.update(); gs.info('Updated sys_number_counter sequencer: ' + oldSeqNumber + ' → ' + nextNumber); } } else { gs.warn('Could not find sys_number_counter record for samp_sp_vb_task. Check the category value manually.'); } gs.info('============================================================'); if (dryRun) { gs.info('DRY RUN COMPLETE. Set dryRun = false to apply changes.'); } else { gs.info('COMPLETE. ' + toRenumber.length + ' records renumbered. Sequencer updated to ' + nextNumber + '.'); } } Script Behavior Summary Identifies duplicates — Queries the samp_sp_vb_task table using GlideAggregate to find Number values with more than one record.Preserves the oldest record — For each duplicate set, the record with the earliest sys_created_on timestamp retains its original Number.Renumbers newer duplicates — Assigns the next available sequential Number (based on the current highest Number on the table) to each duplicate.Updates the sequencer — Modifies the sys_number_counter record for samp_sp_vb_task so future records continue from the correct value.Respects system fields — Uses setWorkflow(false) and autoSysFields(false) to prevent business rules from firing and to preserve the original sys_updated_on and sys_updated_by values. This is a cosmetic issue only. The duplicate Numbers do not affect SAM Value Builder Task functionality or the creation of new tasks. The resolution is recommended to clear Health Scan findings. Related Links<!-- /*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: ; } } .kb-wrapper { font-family: Lato, sans-serif; font-size: 12pt; line-height: 1.7; max-width: 100%; } .kb-wrapper ul { font-family: Lato, sans-serif; font-size: 12pt; margin: 0 0 10px 0; padding-left: 20px; } .kb-wrapper li { margin-bottom: 6px; } .kb-wrapper a { color: #00718F; } SAM Value BuilderAuto-numbering