From e1c1857b6c62ac523d47cf5d04efc67a0f6ca9f9 Mon Sep 17 00:00:00 2001 From: SrijanPatwa <148682493+SrijanPatwa@users.noreply.github.com> Date: Fri, 4 Oct 2024 02:05:39 +0530 Subject: [PATCH 1/5] Create findTableSize.js This script will help to get an idea of the size of tables present in ServiceNow instance and accordingly plan to reduce the instance database footprint. --- Background Scripts/findTableSize.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Background Scripts/findTableSize.js diff --git a/Background Scripts/findTableSize.js b/Background Scripts/findTableSize.js new file mode 100644 index 0000000000..2cfec61992 --- /dev/null +++ b/Background Scripts/findTableSize.js @@ -0,0 +1,11 @@ +var table_name = 'sys_attachment_doc'; //The file data of attachment is stored in this Table in ServiceNow + +var tabSizeinGB = new GlideRecord('sys_physical_table_stats'); +tabSizeinGB.addQuery('table_name', table_name); //Querying with the 'sys_attachment_doc' table to get the size of it +tabSizeinGB.setLimit(1); //This will limit to one record query +tabSizeinGB.query(); +if (tabSizeinGB.next()) { + gs.info('[' + tabSizeinGB.getValue('table_name') +']' + ' table Size is: ' + tabSizeinGB.getValue('table_size_in_gb') + ' GB'); +} else { + gs.info('Table not found!'); +} From ad6479b3de5cedf323732c9470cb9c478edf0bf1 Mon Sep 17 00:00:00 2001 From: SrijanPatwa <148682493+SrijanPatwa@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:36:19 +0530 Subject: [PATCH 2/5] populateGlideListHTML.js Populating glide list field named "SN Company" which utilizes the lightweight_glide_list2 macro to dynamically populate the dropdown with active entries from the core_company table. The form includes "OK" and "Cancel" buttons, enabling users to submit their selection or cancel the action. --- .../populateGlideListHTML.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 UI Pages/Populate Glide List field/populateGlideListHTML.js diff --git a/UI Pages/Populate Glide List field/populateGlideListHTML.js b/UI Pages/Populate Glide List field/populateGlideListHTML.js new file mode 100644 index 0000000000..7733683f1b --- /dev/null +++ b/UI Pages/Populate Glide List field/populateGlideListHTML.js @@ -0,0 +1,32 @@ +//Creating a user interface form that allows users to select a company from a list. The form includes a label prompting +users to select an "SN Company," and utilizes the lightweight_glide_list2 macro to generate a dropdown list populated with active companies from the core_company table. +The form also features "OK" and "Cancel" buttons in the modal footer, which trigger the onSubmit() and onCancel() +functions, respectively, when clicked. This setup facilitates user interaction by enabling the selection of a company, +which can be crucial for various processes within the ServiceNow platform. + + + + + + + + var currRecSysId = RP.getWindowProperties().get('curr_rec_sysid') || ''; + + + + + +
+
+ +

+ +
+ + +
+
From bdf0955cc23e84f92166edc8e4e245ed557e4509 Mon Sep 17 00:00:00 2001 From: SrijanPatwa <148682493+SrijanPatwa@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:38:44 +0530 Subject: [PATCH 3/5] populateGlideListClientScript.js --- .../populateGlideListClientScript.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 UI Pages/Populate Glide List field/populateGlideListClientScript.js diff --git a/UI Pages/Populate Glide List field/populateGlideListClientScript.js b/UI Pages/Populate Glide List field/populateGlideListClientScript.js new file mode 100644 index 0000000000..ad36ef168c --- /dev/null +++ b/UI Pages/Populate Glide List field/populateGlideListClientScript.js @@ -0,0 +1,10 @@ + var splitted = ['0c441abbc6112275000025157c651c89', '820351a1c0a8018b67c73d51c074097c']; //Two arrays are defined: splitted contains unique identifiers (likely Sys IDs), and displayText contains the corresponding display names for each identifier. For example, the first identifier corresponds to "3Com" and the second to "Acer." + var displayText = ['3Com', 'Acer']; + for (var z = 0; z < splitted.length; z++) { + var selEl = document.getElementById('select_0comCollector'); //This line retrieves the HTML select element with the ID select_0comCollector. This element is where the new options will be added. + var optEl = document.createElement('option'); + var txtNd1 = document.createTextNode([displayText[z]]); //A text node is created using the corresponding display name from the displayText array, indexed by z. This node will be the visible text for the option. + optEl.setAttribute('value', [splitted[z]]); //The value of the newly created option is set to the corresponding identifier from the splitted array, indexed by z. + optEl.appendChild(txtNd1); + selEl.appendChild(optEl); //The fully constructed option element is appended to the dropdown select element, making it visible in the user interface. + } From 4aa64784d707db18258e31ad24fbec3cbd0e8762 Mon Sep 17 00:00:00 2001 From: SrijanPatwa <148682493+SrijanPatwa@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:41:51 +0530 Subject: [PATCH 4/5] readme.md --- UI Pages/Populate Glide List field/readme.md | 58 ++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 UI Pages/Populate Glide List field/readme.md diff --git a/UI Pages/Populate Glide List field/readme.md b/UI Pages/Populate Glide List field/readme.md new file mode 100644 index 0000000000..5ac99f0f66 --- /dev/null +++ b/UI Pages/Populate Glide List field/readme.md @@ -0,0 +1,58 @@ +//The UI page includes a label prompting users to select an "SN Company," and utilizes the lightweight_glide_list2 macro to generate a dropdown list populated with active companies from the core_company table. The form also features "OK" and "Cancel" buttons in the modal footer, which trigger the onSubmit() and onCancel() functions, respectively, when clicked. This setup facilitates user interaction by enabling the selection of a company, which can be crucial for various processes within the ServiceNow platform. + + +

+//This code creates a label for the company selection field, indicating that users should select a company from the list. +Company Selection Control: + + + +//This line invokes a macro called lightweight_glide_list2, which creates a dropdown or list control for selecting a company. The parameters specify that it should reference the core_company table, only show active companies (where u_active is true), and allow the user to write (make changes). + + +//This section creates a footer for the modal dialog containing "OK" and "Cancel" buttons. The g:dialog_buttons_ok_cancel macro generates these buttons, calling the onSubmit() function to handle submission when the OK button is clicked and the onCancel() function to handle cancellation when the Cancel button is clicked. + + + + +var splitted = ['0c441abbc6112275000025157c651c89', '820351a1c0a8018b67c73d51c074097c']; +var displayText = ['3Com', 'Acer']; +//Two arrays are defined: splitted contains unique identifiers (likely Sys IDs), and displayText contains the corresponding display names for each identifier. For example, the first identifier corresponds to "3Com" and the second to "Acer." +Loop Through the Arrays: + + +for (var z = 0; z < splitted.length; z++) { +//A for loop is initiated to iterate through the elements of the splitted array. The loop runs as long as z is less than the length of the splitted array, ensuring that each item in both arrays is processed. +Get the Dropdown Element: + +var selEl = document.getElementById('select_0comCollector'); +//This line retrieves the HTML select element with the ID select_0comCollector. This element is where the new options will be added. +Create a New Option Element: + + +var optEl = document.createElement('option'); +//A new