From 1ddb52fea523777ca889711a53d48d881bd5402f Mon Sep 17 00:00:00 2001 From: ChandBasha-code Date: Sun, 12 Oct 2025 19:21:39 +0530 Subject: [PATCH 1/6] Create Dynamic CI Groups --- Specialized Areas/ITOM/Dynamic CI Groups | 1 + 1 file changed, 1 insertion(+) create mode 100644 Specialized Areas/ITOM/Dynamic CI Groups diff --git a/Specialized Areas/ITOM/Dynamic CI Groups b/Specialized Areas/ITOM/Dynamic CI Groups new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Specialized Areas/ITOM/Dynamic CI Groups @@ -0,0 +1 @@ + From 89b66742f8a1ac1e4684b20f156bb4f0fe6606ec Mon Sep 17 00:00:00 2001 From: ChandBasha-code Date: Sun, 12 Oct 2025 19:22:27 +0530 Subject: [PATCH 2/6] Delete Specialized Areas/ITOM/Dynamic CI Groups --- Specialized Areas/ITOM/Dynamic CI Groups | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Specialized Areas/ITOM/Dynamic CI Groups diff --git a/Specialized Areas/ITOM/Dynamic CI Groups b/Specialized Areas/ITOM/Dynamic CI Groups deleted file mode 100644 index 8b13789179..0000000000 --- a/Specialized Areas/ITOM/Dynamic CI Groups +++ /dev/null @@ -1 +0,0 @@ - From 25208fa430f43235d7428c346b716a51ff8baffa Mon Sep 17 00:00:00 2001 From: ChandBasha-code Date: Sun, 12 Oct 2025 19:25:18 +0530 Subject: [PATCH 3/6] Create KeyValueCreationFromDCIgroups.README.md --- .../KeyValueCreationFromDCIgroups.README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Specialized Areas/ITOM/Bulk Location Update/KeyValueCreationFromDCIgroups.README.md diff --git a/Specialized Areas/ITOM/Bulk Location Update/KeyValueCreationFromDCIgroups.README.md b/Specialized Areas/ITOM/Bulk Location Update/KeyValueCreationFromDCIgroups.README.md new file mode 100644 index 0000000000..e398f06431 --- /dev/null +++ b/Specialized Areas/ITOM/Bulk Location Update/KeyValueCreationFromDCIgroups.README.md @@ -0,0 +1,10 @@ +This script automatically creates key-value entries for Configuration Items (CIs) that belong to query-based CMDB groups, ensuring consistent tagging and service association within the CMDB. +It is particularly useful for maintaining Application-level key associations (key = "Application") dynamically — based on group membership from Query-Based Services (cmdb_ci_query_based_service). + +This script automates the process of creating records in the cmdb_key_value table for all CIs belonging to query-based service groups (cmdb_ci_query_based_service) that are linked with CMDB groups. +It ensures that: +* Each CI gets a key-value pair where
key = “Application” and
value = + “AS” +* No duplicate key-value entries are created for the same CI. + + +Build the Tag based mapping define the key and values for every application service and build the map,Here I am grouping CI's with DCI CI Groups. From 48653ba9a0b24a8a2670c46b7c145d47b2c4e8a9 Mon Sep 17 00:00:00 2001 From: ChandBasha-code Date: Sun, 12 Oct 2025 19:26:41 +0530 Subject: [PATCH 4/6] Create TagsCreationFromDCIgroup.js --- .../TagsCreationFromDCIgroup.js | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Specialized Areas/ITOM/Bulk Location Update/TagsCreationFromDCIgroup.js diff --git a/Specialized Areas/ITOM/Bulk Location Update/TagsCreationFromDCIgroup.js b/Specialized Areas/ITOM/Bulk Location Update/TagsCreationFromDCIgroup.js new file mode 100644 index 0000000000..074820fa2a --- /dev/null +++ b/Specialized Areas/ITOM/Bulk Location Update/TagsCreationFromDCIgroup.js @@ -0,0 +1,41 @@ +(function() { + + + var dynamicGroups = new GlideRecord('cmdb_ci_query_based_service'); //Dynamic Ci group + dynamicGroups.addQuery('cmdb_group', '!=', ''); + dynamicGroups.query(); + + var groupSysIds = []; + while(dynamicGroups.next()) { + groupSysIds.push(dynamicGroups.cmdb_group); + } + + + if (groupSysIds.length > 0) { + var cmdbGroupContainsCI = new GlideRecord('cmdb_group_contains_ci'); //Group contains CI's + cmdbGroupContainsCI.addQuery('group', 'IN', groupSysIds.join(',')); + cmdbGroupContainsCI.query(); + + + while (cmdbGroupContainsCI.next()) { + + var keyValue = new GlideRecord('cmdb_key_value'); + keyValue.addQuery('configuration_item', cmdbGroupContainsCI.configuration_item); + keyValue.addQuery('key', 'Application'); + keyValue.query(); + + if (!keyValue.next()) { + // Only insert if not already present + keyValue.initialize(); + keyValue.setValue('configuration_item', cmdbGroupContainsCI.configuration_item); + keyValue.setValue('key', 'Application'); + keyValue.setValue('value', dynamicGroups.name + 'AS'); + keyValue.insert(); + + // Log only for new entries created (optional) + gs.info('Created key-value for CI: ' + cmdbGroupContainsCI.configuration_item + ' in group: ' + dynamicGroups.name + ', SysID: ' + keyValue.sys_id); + } + } + } + +})( ); From 21501bfa8c0b842d10faa9610db7d28a06d7b3fa Mon Sep 17 00:00:00 2001 From: ChandBasha-code Date: Sun, 12 Oct 2025 19:27:10 +0530 Subject: [PATCH 5/6] Rename KeyValueCreationFromDCIgroups.README.md to TagsCreationFromDCIgroups.README.md --- ...romDCIgroups.README.md => TagsCreationFromDCIgroups.README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Specialized Areas/ITOM/Bulk Location Update/{KeyValueCreationFromDCIgroups.README.md => TagsCreationFromDCIgroups.README.md} (100%) diff --git a/Specialized Areas/ITOM/Bulk Location Update/KeyValueCreationFromDCIgroups.README.md b/Specialized Areas/ITOM/Bulk Location Update/TagsCreationFromDCIgroups.README.md similarity index 100% rename from Specialized Areas/ITOM/Bulk Location Update/KeyValueCreationFromDCIgroups.README.md rename to Specialized Areas/ITOM/Bulk Location Update/TagsCreationFromDCIgroups.README.md From 141cfd092c42d1bec221a684bda8962d026486b3 Mon Sep 17 00:00:00 2001 From: ChandBasha-code Date: Mon, 13 Oct 2025 08:28:57 +0530 Subject: [PATCH 6/6] Create TagsCreationFromDCI --- Server-Side Components/Background Scripts/TagsCreationFromDCI | 1 + 1 file changed, 1 insertion(+) create mode 100644 Server-Side Components/Background Scripts/TagsCreationFromDCI diff --git a/Server-Side Components/Background Scripts/TagsCreationFromDCI b/Server-Side Components/Background Scripts/TagsCreationFromDCI new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Server-Side Components/Background Scripts/TagsCreationFromDCI @@ -0,0 +1 @@ +