Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//UI Action for Create De-duplicate Tasks
//Onclick showConfirmationDialog

function showConfirmationDialog() {
var entries = g_list.getChecked();
var sysIDs = entries.split(',');

var con1 = confirm('Total number of Selected CIs ' + sysIDs.length + '. Click OK to create De-duplicate task');

if (con1) {
alert(sysIDs);
var ga = new GlideAjax('createDuplicateCITask');
ga.addParam('sysparm_name', 'createDeDupTask');
ga.addParam('sysparm_entry_ids', entries);
ga.getXML(getDupTasks);
}

function getDupTasks(response) {

var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == null) {
alert('Failed to create Remediate Duplicate Task. Selected CIs are already part of an open Remediate Duplicate Task');
} else {
var url1 = 'reconcile_duplicate_task.do?sys_id=' + answer;
var con = confirm('The De-duplicate task is created. Click OK to redirect to De-duplicate task record');
if (con) {
location.href = url1;
}
}
}
}

//Script Include

var createDuplicateCITask = Class.create();
createDuplicateCITask.prototype = Object.extendsObject(AbstractAjaxProcessor, {
createDeDupTask: function() {
var entries = this.getParameter('sysparm_entry_ids');

var dupTaskUtil = new CMDBDuplicateTaskUtils();
var deDupTaskID = dupTaskUtil.createDuplicateTask(entries);

return deDupTaskID;

},

type: 'createDuplicateCITask'
});


This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,47 +1,22 @@
# CI Deduplication Task Generator

This script rechecks the cmdb_ci_hardware table for duplicates by serial number and creates a De-Duplication Task if needed (for records that didn't run through the IRE).
This repository contains a ServiceNow customization that enables users to create De-Duplicate Tasks for selected Configuration Items (CIs) directly from a list view using a UI Action.

### How It Works

1. Finds all serial numbers that are used on more than one hardware CI.
When executed, the UI Action confirms the number of selected CIs, calls a Script Include via GlideAjax, and creates a Remediate Duplicate Task using CMDBDuplicateTaskUtils

2. For each group of duplicates, it checks if any of the CIs are already part of an open de-duplication task.
### How It Works

3. If no open task exists, it creates a new one linking all CIs in the group.
* Allows users to select multiple CIs and trigger de-duplication in one click
* Automatically creates a De-Duplicate Task record using backend logic
* Displays confirmation dialogs for task creation and redirection
* Prevents duplicate task creation for CIs already linked to an open task
* Redirects to the created De-Duplicate Task record for quick review

4. Logs a summary of actions taken (tasks created, groups skipped).

### Dependencies

This script requires the `global.CMDBDuplicateTaskUtils` Script Include to be active in your instance.

### Configuration & Use

This script is meant to be run as a **Scheduled Job** or as a **Background Script**.

Before you run it, you must set the target table.

```
// Change this line in the script!
var ciTable = "cmdb_ci_hardware"


```

Change `"cmdb_ci_hardware"` to the table you want to run the script against.

### Example Log Output

```
Starting check for duplicate CIs by serial number...
==> Successfully created task RITM0010123 for Serial Number "VMW-50-81-7A-C9-23-44".
--> Skipping Serial Number "SGH814X025". It is already part of an open task.
--- Re-check Complete ---
Total Duplicate Groups Found: 2
New Remediation Tasks Created: 1
Groups Skipped (Already in an open task): 1
--------------------------


```
Creation of UI Action and asking confirmation of selected Records from List View by using GlideAjax
Loading