From aaf822a3f2b61306da04c8b76d7fb491c31ce315 Mon Sep 17 00:00:00 2001 From: Sachin Narayanasamy <132642563+SachinNarayanasamy@users.noreply.github.com> Date: Sun, 19 Oct 2025 23:08:26 +0530 Subject: [PATCH 1/3] Create Auto populate short description --- .../Auto populate short description | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Auto-Populate Short Discription/Auto populate short description diff --git a/Client-Side Components/Client Scripts/Auto-Populate Short Discription/Auto populate short description b/Client-Side Components/Client Scripts/Auto-Populate Short Discription/Auto populate short description new file mode 100644 index 0000000000..ab05f00a7c --- /dev/null +++ b/Client-Side Components/Client Scripts/Auto-Populate Short Discription/Auto populate short description @@ -0,0 +1,29 @@ +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || newValue === '') { + return; + } + + // Define category-to-short description mapping + var categoryToShortDescription = { + 'hardware': 'Hardware Issue - ', + 'software': 'Software Issue - ', + 'network': 'Network Issue - ', + 'inquiry': 'Inquiry/Help - ', + 'database': 'Database - ' + }; + + // Convert the selected value to lowercase for matching + var selectedCategory = newValue.toLowerCase(); + + // If category exists in mapping, update the short description + if (categoryToShortDescription.hasOwnProperty(selectedCategory)) { + var existingDesc = g_form.getValue('short_description') || ''; + var prefix = categoryToShortDescription[selectedCategory]; + + // Only add prefix if it's not already there + if (!existingDesc.startsWith(prefix)) { + g_form.setValue('short_description', prefix + existingDesc); + g_form.showFieldMsg('short_description', 'Short Description auto-updated based on category.', 'info'); + } + } +} From a0f7f5f1cce99fa5e91cb3caa997c7910e060266 Mon Sep 17 00:00:00 2001 From: Sachin Narayanasamy <132642563+SachinNarayanasamy@users.noreply.github.com> Date: Sun, 19 Oct 2025 23:10:11 +0530 Subject: [PATCH 2/3] Create Readme.md --- .../Auto-Populate Short Discription/Readme.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Auto-Populate Short Discription/Readme.md diff --git a/Client-Side Components/Client Scripts/Auto-Populate Short Discription/Readme.md b/Client-Side Components/Client Scripts/Auto-Populate Short Discription/Readme.md new file mode 100644 index 0000000000..7bf56626d9 --- /dev/null +++ b/Client-Side Components/Client Scripts/Auto-Populate Short Discription/Readme.md @@ -0,0 +1,45 @@ +Auto-Populate Short Description (Client Script) +Overview + +This client script automatically updates the Short Description field in ServiceNow whenever a user selects a category on the form. It improves data consistency, saves time, and ensures that short descriptions remain meaningful and standardized. + +How It Works + +When a user selects a category such as Hardware, Software, or Network, the script automatically prefixes the existing short description with a corresponding label (for example, “Hardware Issue –”). +This makes incident records easier to identify and improves the quality of data entry. + +Configuration Steps + +Log in to your ServiceNow instance with admin or developer access. + +Navigate to System Definition → Client Scripts. + +Create a new Client Script with the following details: + +Table: Incident + +Type: onChange + +Field name: category + +Copy and paste the provided script into the Script field. + +Save the record and make sure the script is active. + +Testing + +Open any existing or new Incident record. + +Select a category such as Hardware or Software. + +The Short Description field will automatically update with the corresponding prefix. + +Benefits + +Speeds up data entry for users. + +Maintains consistency in short descriptions. + +Reduces manual effort and human errors. + +Enhances clarity in incident listings and reports. From 1fd3c17a6cdd3d06d2430cec4859815ced35643a Mon Sep 17 00:00:00 2001 From: Sachin Narayanasamy <132642563+SachinNarayanasamy@users.noreply.github.com> Date: Mon, 20 Oct 2025 02:13:48 +0530 Subject: [PATCH 3/3] Rename Auto populate short description to Auto populate short description.js --- ...ulate short description => Auto populate short description.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Client-Side Components/Client Scripts/Auto-Populate Short Discription/{Auto populate short description => Auto populate short description.js} (100%) diff --git a/Client-Side Components/Client Scripts/Auto-Populate Short Discription/Auto populate short description b/Client-Side Components/Client Scripts/Auto-Populate Short Discription/Auto populate short description.js similarity index 100% rename from Client-Side Components/Client Scripts/Auto-Populate Short Discription/Auto populate short description rename to Client-Side Components/Client Scripts/Auto-Populate Short Discription/Auto populate short description.js