Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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');
}
}
}
Original file line number Diff line number Diff line change
@@ -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.
Loading