From f54c78ae32d8c9857a2d6a1d4886a2687eb911dd Mon Sep 17 00:00:00 2001
From: Pradeep567iaf <60265769+Pradeep567iaf@users.noreply.github.com>
Date: Mon, 28 Oct 2024 16:54:30 +0530
Subject: [PATCH 1/6] Add files via upload
This UI Page was developed to streamline the update process of the Install Status field for CMDB (Configuration Management Database) items in ServiceNow. Using Jelly XML scripting, the UI Page fetches details for a selected CI item, allows users to modify the Install Status, and save changes back to the CMDB record. Client script and Script include als used to fetch configuration item data and update it to table.
---
.../ci_lifecycle_ui_page.xml | 136 ++++++++++++++++++
.../client_script.js | 53 +++++++
.../script_include.js | 39 +++++
3 files changed, 228 insertions(+)
create mode 100644 UI Pages/CI lifecycle Management UI page/ci_lifecycle_ui_page.xml
create mode 100644 UI Pages/CI lifecycle Management UI page/client_script.js
create mode 100644 UI Pages/CI lifecycle Management UI page/script_include.js
diff --git a/UI Pages/CI lifecycle Management UI page/ci_lifecycle_ui_page.xml b/UI Pages/CI lifecycle Management UI page/ci_lifecycle_ui_page.xml
new file mode 100644
index 0000000000..6596b82d88
--- /dev/null
+++ b/UI Pages/CI lifecycle Management UI page/ci_lifecycle_ui_page.xml
@@ -0,0 +1,136 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UI Pages/CI lifecycle Management UI page/client_script.js b/UI Pages/CI lifecycle Management UI page/client_script.js
new file mode 100644
index 0000000000..46719454c8
--- /dev/null
+++ b/UI Pages/CI lifecycle Management UI page/client_script.js
@@ -0,0 +1,53 @@
+/* function to fetch the configuration item details like serial No, name , class , install status */
+function searchCI() {
+ var ciNameorId = document.getElementById('ci_input').value;
+ if (!ciNameorId) {
+ alert('Please Enter the Configuration item Name or ID');
+ } else {
+ var ga = new GlideAjax('ci_lifecycle_management_script_include');
+ ga.addParam('sysparm_name', 'get_ci_info');
+ ga.addParam('sysparm_ci_name_or_id', ciNameorId);
+ ga.getXMLAnswer(function(response) {
+ var record = JSON.parse(response);
+ document.getElementById("ci-info").style.display = "block";
+ document.getElementById('ci_name').innerText = record.name;
+ document.getElementById('serial_number').innerText = record.serial_number;
+ document.getElementById('ci_class').innerText = record.ci_class;
+ document.getElementById('ci_install_status').innerText = record.ci_install_status;
+ var operations = ['Stolen', 'Retired','In Stock','In Maintenance'];
+ operations.forEach((operation) => {
+ var hidden_ele_id = operation.replace(/\s+/g, "");
+ var elementId = "ci_"+hidden_ele_id;
+ var ele = document.getElementById(elementId);
+ if(operation == record.ci_install_status){
+ ele.style.display = "none";
+ }
+ });
+ });
+ }
+}
+/* end of searchCI() */
+
+/* function to update the status of Configuration item */
+function UpdateCI(status) {
+ var ciNameorId = document.getElementById('ci_input').value;
+ if (ciNameorId) {
+ var updateci = new GlideAjax('ci_lifecycle_management_script_include');
+ updateci.addParam('sysparm_name', 'update_ci_info');
+ updateci.addParam('sysparm_ci_id_or_name', ciNameorId);
+ updateci.addParam('sysparm_ci_status', status);
+ updateci.getXMLAnswer(function(response) {
+ var result = JSON.parse(response);
+ if(result.updated == true){
+ alert("Record Updated Successfully");
+ }
+
+ });
+
+
+ } else {
+ alert('Facing issues to Update the CI');
+ }
+
+}
+/* function to update the status of Configuration item */
\ No newline at end of file
diff --git a/UI Pages/CI lifecycle Management UI page/script_include.js b/UI Pages/CI lifecycle Management UI page/script_include.js
new file mode 100644
index 0000000000..fc024a37b3
--- /dev/null
+++ b/UI Pages/CI lifecycle Management UI page/script_include.js
@@ -0,0 +1,39 @@
+var ci_lifecycle_management_script_include = Class.create(); // script include class name
+ci_lifecycle_management_script_include.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
+ /* function to query the cmdb_ci table to update the status of configuration item */
+ update_ci_info: function() {
+ var ci_id = this.getParameter('sysparm_ci_id_or_name');
+ var cistatus = this.getParameter('sysparm_ci_status');
+ var gr = new GlideRecord('cmdb_ci');
+ gr.addQuery('sys_id',ci_id);
+ gr.query();
+ if(gr.next()){
+ gr.setValue('install_status', cistatus);
+ gr.update();
+ return JSON.stringify({
+ "updated":true
+ });
+ }
+ },
+ /* end of update_ci_info function */
+
+
+ /* function to query the cmdb_ci table to fetch configuration item details according to ci sys_id*/
+ get_ci_info:function(){
+ var ciNameOrId = this.getParameter('sysparm_ci_name_or_id');
+ var gr = new GlideRecord('cmdb_ci');
+ if(gr.get(ciNameOrId)){
+ var record = {
+ success:true,
+ name: gr.getValue('name'),
+ serial_number: gr.getValue('serial_number'),
+ ci_class : gr.getValue('sys_class_name'),
+ ci_install_status : gr.getDisplayValue('install_status')
+ };
+ return JSON.stringify(record);
+
+ }
+ },
+ /* end of get_ci_info() */
+ type: 'ci_lifecycle_management_script_include'
+});
\ No newline at end of file
From 8abfca4360d27ec64233c5b30a40dff4530d7a06 Mon Sep 17 00:00:00 2001
From: Pradeep567iaf <60265769+Pradeep567iaf@users.noreply.github.com>
Date: Mon, 28 Oct 2024 16:55:52 +0530
Subject: [PATCH 2/6] Delete UI Pages/CI lifecycle Management UI page directory
---
.../ci_lifecycle_ui_page.xml | 136 ------------------
.../client_script.js | 53 -------
.../script_include.js | 39 -----
3 files changed, 228 deletions(-)
delete mode 100644 UI Pages/CI lifecycle Management UI page/ci_lifecycle_ui_page.xml
delete mode 100644 UI Pages/CI lifecycle Management UI page/client_script.js
delete mode 100644 UI Pages/CI lifecycle Management UI page/script_include.js
diff --git a/UI Pages/CI lifecycle Management UI page/ci_lifecycle_ui_page.xml b/UI Pages/CI lifecycle Management UI page/ci_lifecycle_ui_page.xml
deleted file mode 100644
index 6596b82d88..0000000000
--- a/UI Pages/CI lifecycle Management UI page/ci_lifecycle_ui_page.xml
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/UI Pages/CI lifecycle Management UI page/client_script.js b/UI Pages/CI lifecycle Management UI page/client_script.js
deleted file mode 100644
index 46719454c8..0000000000
--- a/UI Pages/CI lifecycle Management UI page/client_script.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/* function to fetch the configuration item details like serial No, name , class , install status */
-function searchCI() {
- var ciNameorId = document.getElementById('ci_input').value;
- if (!ciNameorId) {
- alert('Please Enter the Configuration item Name or ID');
- } else {
- var ga = new GlideAjax('ci_lifecycle_management_script_include');
- ga.addParam('sysparm_name', 'get_ci_info');
- ga.addParam('sysparm_ci_name_or_id', ciNameorId);
- ga.getXMLAnswer(function(response) {
- var record = JSON.parse(response);
- document.getElementById("ci-info").style.display = "block";
- document.getElementById('ci_name').innerText = record.name;
- document.getElementById('serial_number').innerText = record.serial_number;
- document.getElementById('ci_class').innerText = record.ci_class;
- document.getElementById('ci_install_status').innerText = record.ci_install_status;
- var operations = ['Stolen', 'Retired','In Stock','In Maintenance'];
- operations.forEach((operation) => {
- var hidden_ele_id = operation.replace(/\s+/g, "");
- var elementId = "ci_"+hidden_ele_id;
- var ele = document.getElementById(elementId);
- if(operation == record.ci_install_status){
- ele.style.display = "none";
- }
- });
- });
- }
-}
-/* end of searchCI() */
-
-/* function to update the status of Configuration item */
-function UpdateCI(status) {
- var ciNameorId = document.getElementById('ci_input').value;
- if (ciNameorId) {
- var updateci = new GlideAjax('ci_lifecycle_management_script_include');
- updateci.addParam('sysparm_name', 'update_ci_info');
- updateci.addParam('sysparm_ci_id_or_name', ciNameorId);
- updateci.addParam('sysparm_ci_status', status);
- updateci.getXMLAnswer(function(response) {
- var result = JSON.parse(response);
- if(result.updated == true){
- alert("Record Updated Successfully");
- }
-
- });
-
-
- } else {
- alert('Facing issues to Update the CI');
- }
-
-}
-/* function to update the status of Configuration item */
\ No newline at end of file
diff --git a/UI Pages/CI lifecycle Management UI page/script_include.js b/UI Pages/CI lifecycle Management UI page/script_include.js
deleted file mode 100644
index fc024a37b3..0000000000
--- a/UI Pages/CI lifecycle Management UI page/script_include.js
+++ /dev/null
@@ -1,39 +0,0 @@
-var ci_lifecycle_management_script_include = Class.create(); // script include class name
-ci_lifecycle_management_script_include.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
- /* function to query the cmdb_ci table to update the status of configuration item */
- update_ci_info: function() {
- var ci_id = this.getParameter('sysparm_ci_id_or_name');
- var cistatus = this.getParameter('sysparm_ci_status');
- var gr = new GlideRecord('cmdb_ci');
- gr.addQuery('sys_id',ci_id);
- gr.query();
- if(gr.next()){
- gr.setValue('install_status', cistatus);
- gr.update();
- return JSON.stringify({
- "updated":true
- });
- }
- },
- /* end of update_ci_info function */
-
-
- /* function to query the cmdb_ci table to fetch configuration item details according to ci sys_id*/
- get_ci_info:function(){
- var ciNameOrId = this.getParameter('sysparm_ci_name_or_id');
- var gr = new GlideRecord('cmdb_ci');
- if(gr.get(ciNameOrId)){
- var record = {
- success:true,
- name: gr.getValue('name'),
- serial_number: gr.getValue('serial_number'),
- ci_class : gr.getValue('sys_class_name'),
- ci_install_status : gr.getDisplayValue('install_status')
- };
- return JSON.stringify(record);
-
- }
- },
- /* end of get_ci_info() */
- type: 'ci_lifecycle_management_script_include'
-});
\ No newline at end of file
From daa957b1a051903ac24acbf642602bf367fca864 Mon Sep 17 00:00:00 2001
From: Pradeep567iaf <60265769+Pradeep567iaf@users.noreply.github.com>
Date: Mon, 28 Oct 2024 17:03:46 +0530
Subject: [PATCH 3/6] Create ci_lifecycle_ui_page.xml
jelly page to user to fetch ci data and update configuration item status
---
.../ci_lifecycle_ui_page.xml | 136 ++++++++++++++++++
1 file changed, 136 insertions(+)
create mode 100644 UI Pages/CMDB CI Management UI page/ci_lifecycle_ui_page.xml
diff --git a/UI Pages/CMDB CI Management UI page/ci_lifecycle_ui_page.xml b/UI Pages/CMDB CI Management UI page/ci_lifecycle_ui_page.xml
new file mode 100644
index 0000000000..0d2a116d8f
--- /dev/null
+++ b/UI Pages/CMDB CI Management UI page/ci_lifecycle_ui_page.xml
@@ -0,0 +1,136 @@
+
+
+
+
+
+
+
+
+
+
+
From 02e47311372a67998e7b64215448a6d2e7fe15e9 Mon Sep 17 00:00:00 2001
From: Pradeep567iaf <60265769+Pradeep567iaf@users.noreply.github.com>
Date: Mon, 28 Oct 2024 17:05:29 +0530
Subject: [PATCH 4/6] Create client_srcript.js
Client script file to glide Ajax the script include to query database table cmdb_ci to fetch ci records and update the ci record status
---
.../client_srcript.js | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100644 UI Pages/CMDB CI Management UI page/client_srcript.js
diff --git a/UI Pages/CMDB CI Management UI page/client_srcript.js b/UI Pages/CMDB CI Management UI page/client_srcript.js
new file mode 100644
index 0000000000..6b582725d8
--- /dev/null
+++ b/UI Pages/CMDB CI Management UI page/client_srcript.js
@@ -0,0 +1,53 @@
+/* function to fetch the configuration item details like serial No, name , class , install status */
+function searchCI() {
+ var ciNameorId = document.getElementById('ci_input').value;
+ if (!ciNameorId) {
+ alert('Please Enter the Configuration item Name or ID');
+ } else {
+ var ga = new GlideAjax('ci_lifecycle_management_script_include');
+ ga.addParam('sysparm_name', 'get_ci_info');
+ ga.addParam('sysparm_ci_name_or_id', ciNameorId);
+ ga.getXMLAnswer(function(response) {
+ var record = JSON.parse(response);
+ document.getElementById("ci-info").style.display = "block";
+ document.getElementById('ci_name').innerText = record.name;
+ document.getElementById('serial_number').innerText = record.serial_number;
+ document.getElementById('ci_class').innerText = record.ci_class;
+ document.getElementById('ci_install_status').innerText = record.ci_install_status;
+ var operations = ['Stolen', 'Retired','In Stock','In Maintenance'];
+ operations.forEach((operation) => {
+ var hidden_ele_id = operation.replace(/\s+/g, "");
+ var elementId = "ci_"+hidden_ele_id;
+ var ele = document.getElementById(elementId);
+ if(operation == record.ci_install_status){
+ ele.style.display = "none";
+ }
+ });
+ });
+ }
+}
+/* end of searchCI() */
+
+/* function to update the status of Configuration item */
+function UpdateCI(status) {
+ var ciNameorId = document.getElementById('ci_input').value;
+ if (ciNameorId) {
+ var updateci = new GlideAjax('ci_lifecycle_management_script_include');
+ updateci.addParam('sysparm_name', 'update_ci_info');
+ updateci.addParam('sysparm_ci_id_or_name', ciNameorId);
+ updateci.addParam('sysparm_ci_status', status);
+ updateci.getXMLAnswer(function(response) {
+ var result = JSON.parse(response);
+ if(result.updated == true){
+ alert("Record Updated Successfully");
+ }
+
+ });
+
+
+ } else {
+ alert('Facing issues to Update the CI');
+ }
+
+}
+/* function to update the status of Configuration item */
From d6b3acb70f5e8c1c2f94378099a5150aa578d10f Mon Sep 17 00:00:00 2001
From: Pradeep567iaf <60265769+Pradeep567iaf@users.noreply.github.com>
Date: Mon, 28 Oct 2024 17:07:35 +0530
Subject: [PATCH 5/6] Create ci_script_include.js
script include file to create a backend logic to fetch configuration item records and update the status retired , in maintenance, in stock and stolen
---
.../ci_script_include.js | 39 +++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 UI Pages/CMDB CI Management UI page/ci_script_include.js
diff --git a/UI Pages/CMDB CI Management UI page/ci_script_include.js b/UI Pages/CMDB CI Management UI page/ci_script_include.js
new file mode 100644
index 0000000000..3d681db1ce
--- /dev/null
+++ b/UI Pages/CMDB CI Management UI page/ci_script_include.js
@@ -0,0 +1,39 @@
+var ci_lifecycle_management_script_include = Class.create(); // script include class name
+ci_lifecycle_management_script_include.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
+ /* function to query the cmdb_ci table to update the status of configuration item */
+ update_ci_info: function() {
+ var ci_id = this.getParameter('sysparm_ci_id_or_name');
+ var cistatus = this.getParameter('sysparm_ci_status');
+ var gr = new GlideRecord('cmdb_ci');
+ gr.addQuery('sys_id',ci_id);
+ gr.query();
+ if(gr.next()){
+ gr.setValue('install_status', cistatus);
+ gr.update();
+ return JSON.stringify({
+ "updated":true
+ });
+ }
+ },
+ /* end of update_ci_info function */
+
+
+ /* function to query the cmdb_ci table to fetch configuration item details according to ci sys_id*/
+ get_ci_info:function(){
+ var ciNameOrId = this.getParameter('sysparm_ci_name_or_id');
+ var gr = new GlideRecord('cmdb_ci');
+ if(gr.get(ciNameOrId)){
+ var record = {
+ success:true,
+ name: gr.getValue('name'),
+ serial_number: gr.getValue('serial_number'),
+ ci_class : gr.getValue('sys_class_name'),
+ ci_install_status : gr.getDisplayValue('install_status')
+ };
+ return JSON.stringify(record);
+
+ }
+ },
+ /* end of get_ci_info() */
+ type: 'ci_lifecycle_management_script_include'
+});
From 62896e7279966e64b4b65fdd7875f4df0a1d5fe2 Mon Sep 17 00:00:00 2001
From: Pradeep567iaf <60265769+Pradeep567iaf@users.noreply.github.com>
Date: Mon, 28 Oct 2024 17:08:45 +0530
Subject: [PATCH 6/6] Rename client_srcript.js to ci_client_script.js
update name
---
.../{client_srcript.js => ci_client_script.js} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename UI Pages/CMDB CI Management UI page/{client_srcript.js => ci_client_script.js} (100%)
diff --git a/UI Pages/CMDB CI Management UI page/client_srcript.js b/UI Pages/CMDB CI Management UI page/ci_client_script.js
similarity index 100%
rename from UI Pages/CMDB CI Management UI page/client_srcript.js
rename to UI Pages/CMDB CI Management UI page/ci_client_script.js