Skip to content

Commit 9a8fe4f

Browse files
Creation of De-Duplication Tasks for Manually found Duplicate Records with UI Action (ServiceNowDevProgram#1836)
* Create De-duplicationTasksButton Creation of De-duplicate Tasks manually found duplicate records with UI Action. * Delete Specialized Areas/ITOM/De-duplicationTasksButton * Create De-Duplication Tasks Creation Creation of De-duplication Task with UI Action for Manually found Duplicate records * Delete Specialized Areas/CMDB/De-Duplication Tasks Creation * Create De-duplication Task Creation With UI Action Create De-duplication Task Creation With UI Action * Update README.md * Update and rename CI Deduplication Tasks Generation.js to CI Deduplication Tasks Generation with UI Action.js * Delete Specialized Areas/CMDB/CMDB CI Deduplication Task Generator/De-duplication Task Creation With UI Action
1 parent e802414 commit 9a8fe4f

File tree

3 files changed

+59
-108
lines changed

3 files changed

+59
-108
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//UI Action for Create De-duplicate Tasks
2+
//Onclick showConfirmationDialog
3+
4+
function showConfirmationDialog() {
5+
var entries = g_list.getChecked();
6+
var sysIDs = entries.split(',');
7+
8+
var con1 = confirm('Total number of Selected CIs ' + sysIDs.length + '. Click OK to create De-duplicate task');
9+
10+
if (con1) {
11+
alert(sysIDs);
12+
var ga = new GlideAjax('createDuplicateCITask');
13+
ga.addParam('sysparm_name', 'createDeDupTask');
14+
ga.addParam('sysparm_entry_ids', entries);
15+
ga.getXML(getDupTasks);
16+
}
17+
18+
function getDupTasks(response) {
19+
20+
var answer = response.responseXML.documentElement.getAttribute("answer");
21+
if (answer == null) {
22+
alert('Failed to create Remediate Duplicate Task. Selected CIs are already part of an open Remediate Duplicate Task');
23+
} else {
24+
var url1 = 'reconcile_duplicate_task.do?sys_id=' + answer;
25+
var con = confirm('The De-duplicate task is created. Click OK to redirect to De-duplicate task record');
26+
if (con) {
27+
location.href = url1;
28+
}
29+
}
30+
}
31+
}
32+
33+
//Script Include
34+
35+
var createDuplicateCITask = Class.create();
36+
createDuplicateCITask.prototype = Object.extendsObject(AbstractAjaxProcessor, {
37+
createDeDupTask: function() {
38+
var entries = this.getParameter('sysparm_entry_ids');
39+
40+
var dupTaskUtil = new CMDBDuplicateTaskUtils();
41+
var deDupTaskID = dupTaskUtil.createDuplicateTask(entries);
42+
43+
return deDupTaskID;
44+
45+
},
46+
47+
type: 'createDuplicateCITask'
48+
});
49+
50+

Specialized Areas/CMDB/CMDB CI Deduplication Task Generator/CI Deduplication Tasks Generation.js

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,22 @@
11
# CI Deduplication Task Generator
22

3-
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).
3+
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.
44

5-
### How It Works
6-
7-
1. Finds all serial numbers that are used on more than one hardware CI.
5+
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
86

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

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

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

1516
### Dependencies
1617

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

1920
### Configuration & Use
2021

21-
This script is meant to be run as a **Scheduled Job** or as a **Background Script**.
22-
23-
Before you run it, you must set the target table.
24-
25-
```
26-
// Change this line in the script!
27-
var ciTable = "cmdb_ci_hardware"
28-
29-
30-
```
31-
32-
Change `"cmdb_ci_hardware"` to the table you want to run the script against.
33-
34-
### Example Log Output
35-
36-
```
37-
Starting check for duplicate CIs by serial number...
38-
==> Successfully created task RITM0010123 for Serial Number "VMW-50-81-7A-C9-23-44".
39-
--> Skipping Serial Number "SGH814X025". It is already part of an open task.
40-
--- Re-check Complete ---
41-
Total Duplicate Groups Found: 2
42-
New Remediation Tasks Created: 1
43-
Groups Skipped (Already in an open task): 1
44-
--------------------------
45-
46-
47-
```
22+
Creation of UI Action and asking confirmation of selected Records from List View by using GlideAjax

0 commit comments

Comments
 (0)