|
| 1 | +🧩 Readme : Client Script: Auto Priority Update Based on Impact and Urgency |
| 2 | +📘 Overview |
| 3 | + |
| 4 | +This client script automatically updates the Priority field on the Incident form whenever the Impact or Urgency value changes. |
| 5 | +It follows the ITIL standard mapping to ensure the correct priority is always set automatically, improving data accuracy and efficiency for service desk agents. |
| 6 | + |
| 7 | +⚙️ Script Details |
| 8 | +Field Value |
| 9 | +Name Auto Priority Update based on Impact and Urgency |
| 10 | +Type onChange |
| 11 | +Applies to Table Incident |
| 12 | +Applies on Fields impact, urgency |
| 13 | +UI Type All (Classic, Mobile, Workspace) |
| 14 | +Active ✅ Yes |
| 15 | +Condition Leave blank |
| 16 | +💻 Script Code |
| 17 | +// ========================================================================== |
| 18 | +// Script Name: Auto Priority Update based on Impact and Urgency |
| 19 | +// Table: Incident |
| 20 | +// Type: onChange | Fields: impact, urgency |
| 21 | +// UI Type: All |
| 22 | +// Version: 2025 Production Ready |
| 23 | +// ========================================================================== |
| 24 | + |
| 25 | +function onChange(control, oldValue, newValue, isLoading, isTemplate) { |
| 26 | + // Skip execution if form is loading or field is empty |
| 27 | + if (isLoading || newValue == '') { |
| 28 | + return; |
| 29 | + } |
| 30 | + |
| 31 | + // Get Impact and Urgency values |
| 32 | + var impact = g_form.getValue('impact'); |
| 33 | + var urgency = g_form.getValue('urgency'); |
| 34 | + |
| 35 | + // Define Priority Matrix (ITIL standard) |
| 36 | + var priorityMatrix = { |
| 37 | + '1': { '1': '1', '2': '2', '3': '3' }, |
| 38 | + '2': { '1': '2', '2': '3', '3': '4' }, |
| 39 | + '3': { '1': '3', '2': '4', '3': '5' } |
| 40 | + }; |
| 41 | + |
| 42 | + // Find the new Priority |
| 43 | + var newPriority = priorityMatrix[impact]?.[urgency]; |
| 44 | + |
| 45 | + // Update the Priority field if valid |
| 46 | + if (newPriority) { |
| 47 | + if (g_form.getValue('priority') != newPriority) { |
| 48 | + g_form.setValue('priority', newPriority); |
| 49 | + g_form.showFieldMsg('priority', 'Priority auto-updated based on Impact and Urgency', 'info'); |
| 50 | + } |
| 51 | + } else { |
| 52 | + // Optional: Clear Priority if invalid combination is selected |
| 53 | + g_form.clearValue('priority'); |
| 54 | + g_form.showFieldMsg('priority', 'Invalid Impact/Urgency combination — priority cleared', 'error'); |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +🧠 How It Works |
| 59 | + |
| 60 | +The script runs automatically when Impact or Urgency changes. |
| 61 | +It checks the ITIL-based matrix to determine the correct Priority. |
| 62 | +If a valid combination is found, the Priority field updates automatically. |
| 63 | +A small info message appears to confirm the update. |
| 64 | + |
| 65 | +🔢 ITIL Mapping Table |
| 66 | +Impact Urgency Resulting Priority |
| 67 | +1 (High) 1 (High) 1 (Critical) |
| 68 | +1 2 2 |
| 69 | +1 3 3 |
| 70 | +2 1 2 |
| 71 | +2 2 3 |
| 72 | +2 3 4 |
| 73 | +3 1 3 |
| 74 | +3 2 4 |
| 75 | +3 3 5 |
| 76 | +✅ Benefits |
| 77 | + |
| 78 | +Automatically enforces ITIL priority standards |
| 79 | +Reduces manual effort and user errors |
| 80 | +Ensures consistency in priority calculation |
| 81 | +Compatible with Classic UI, Next Experience, and Agent Workspace |
0 commit comments