diff --git a/Client-Side Components/Client Scripts/Set Urgency to High onChange of caller field/Readme.md b/Client-Side Components/Client Scripts/Set Urgency to High onChange of caller field/Readme.md new file mode 100644 index 0000000000..57d1ee1e3e --- /dev/null +++ b/Client-Side Components/Client Scripts/Set Urgency to High onChange of caller field/Readme.md @@ -0,0 +1,39 @@ +VIP Caller — Auto-Set Urgency Client Script (ServiceNow) +Overview + +This Client Script automatically sets the Urgency field to High (1) whenever a VIP caller is selected on a ServiceNow form. + +It also shows a field-level info message to notify the user why urgency was updated. The script ignores non-VIP callers, ensuring normal behavior for regular users. + +Features + +Automatically detects when a VIP caller is selected. + +Sets the Urgency field to High (1). + +Displays a field-level message below the urgency field ("Urgency automatically set to High because caller is VIP"). + +Works dynamically every time the caller field changes. + +Compatible with Classic UI forms. + +Ensures non-VIP callers do not trigger urgency changes. + +Usage Instructions +1. Create the Client Script + +Navigate to System Definition → Client Scripts. + +Click New to create a client script. + +2. Configure the Script + +Name: VIP Caller Urgency + +Table: incident + +Type: onChange + +Field: caller_id + +Active: Checked diff --git a/Client-Side Components/Client Scripts/Set Urgency to High onChange of caller field/Set Urgency to High when Caller Change.js b/Client-Side Components/Client Scripts/Set Urgency to High onChange of caller field/Set Urgency to High when Caller Change.js new file mode 100644 index 0000000000..6fea361867 --- /dev/null +++ b/Client-Side Components/Client Scripts/Set Urgency to High onChange of caller field/Set Urgency to High when Caller Change.js @@ -0,0 +1,23 @@ +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || newValue === '') { + return; + } + + g_form.getReference('caller_id', function(caller) { + if (caller.vip === true || caller.vip === 'true') { + g_form.setValue('urgency', '1'); + + if (g_form.showFieldMsg) { + g_form.showFieldMsg( + 'urgency', + 'Urgency automatically set to High because caller is VIP', + 'info', + false + ); + } + } else { + // Optional: Do nothing or reset urgency + // g_form.setValue('urgency', oldValue); + } + }); +}