diff --git a/Client-Side Components/Client Scripts/Highlight Priority Field/HighlightPriorityField.js b/Client-Side Components/Client Scripts/Highlight Priority Field/HighlightPriorityField.js new file mode 100644 index 0000000000..579777b356 --- /dev/null +++ b/Client-Side Components/Client Scripts/Highlight Priority Field/HighlightPriorityField.js @@ -0,0 +1,37 @@ +function onLoad() { + var priority = g_form.getValue('priority'); + var control = g_form.getControl('priority'); + + if (control) { + switch (priority) { + case '1': // Critical + control.style.backgroundColor = '#ff4d4d'; + control.style.color = 'white'; + control.style.fontWeight = 'bold'; + break; + case '2': // High + control.style.backgroundColor = '#ffa500'; + control.style.color = 'black'; + control.style.fontWeight = 'bold'; + break; + case '3': // Moderate + control.style.backgroundColor = '#ffff66'; + control.style.color = 'black'; + control.style.fontWeight = 'bold'; + break; + case '4': // Low + control.style.backgroundColor = '#d3ffd3'; + control.style.color = 'black'; + control.style.fontWeight = 'bold'; + break; + case '5': // Planning + control.style.backgroundColor = '#e0e0e0'; + control.style.color = 'black'; + control.style.fontWeight = 'bold'; + break; + default: + control.style.backgroundColor = ''; + control.style.fontWeight = 'normal'; + } + } +} diff --git a/Client-Side Components/Client Scripts/Highlight Priority Field/READEME.md b/Client-Side Components/Client Scripts/Highlight Priority Field/READEME.md new file mode 100644 index 0000000000..7dd44e6b1d --- /dev/null +++ b/Client-Side Components/Client Scripts/Highlight Priority Field/READEME.md @@ -0,0 +1,71 @@ +# 🟢 Highlight Incident Priority Field + +## Overview +This **ServiceNow Client Script** enhances the user experience on the *Incident* form by visually highlighting the **priority field** using color indicators. +It helps agents quickly identify the urgency of a ticket based on its priority level. + +--- + +## Features +- 🎨 Runs automatically on form load (`onLoad`) +- ⚡ Applies background and text color styling to the `priority` field +- 🧠 Uses distinct colors for each priority level: + - **Critical (1)** → Red + - **High (2)** → Orange + - **Moderate (3)** → Yellow + - **Low (4)** → Light Green + - **Planning (5)** → Gray + +--- + +## Configuration + +| **Property** | **Value** | +|---------------|-----------| +| **Table** | `incident` | +| **Type** | `onLoad` | +| **Script Name** | `Highlight Priority Field` | +| **Active** | `true` | + +--- + +## Script + +```javascript +function onLoad() { + var priority = g_form.getValue('priority'); + var control = g_form.getControl('priority'); + + if (control) { + switch (priority) { + case '1': // Critical + control.style.backgroundColor = '#ff4d4d'; // Red + control.style.color = 'white'; + control.style.fontWeight = 'bold'; + break; + case '2': // High + control.style.backgroundColor = '#ffa500'; // Orange + control.style.color = 'black'; + control.style.fontWeight = 'bold'; + break; + case '3': // Moderate + control.style.backgroundColor = '#ffff66'; // Yellow + control.style.color = 'black'; + control.style.fontWeight = 'bold'; + break; + case '4': // Low + control.style.backgroundColor = '#d3ffd3'; // Light Green + control.style.color = 'black'; + control.style.fontWeight = 'bold'; + break; + case '5': // Planning + control.style.backgroundColor = '#e0e0e0'; // Gray + control.style.color = 'black'; + control.style.fontWeight = 'bold'; + break; + default: + control.style.backgroundColor = ''; // Reset + control.style.fontWeight = 'normal'; + } + } +}