diff --git a/Client-Side Components/Client Scripts/Warn Before Closing Incident Without Work Notes/README.md b/Client-Side Components/Client Scripts/Warn Before Closing Incident Without Work Notes/README.md new file mode 100644 index 0000000000..409edfd2c2 --- /dev/null +++ b/Client-Side Components/Client Scripts/Warn Before Closing Incident Without Work Notes/README.md @@ -0,0 +1,32 @@ +# Warn Before Closing Incident Without Work Notes + +## Overview +This Client Script prevents users from resolving or closing an Incident without adding work notes. It ensures that important resolution details are documented before the ticket is closed. + +## Features +- Triggered on form submission. +- Checks if the Incident state is set to Resolved or Closed. +- Displays a warning if Work Notes are empty. +- Prevents form submission until notes are added. + +## Configuration + +- **Table**: `incident` +- **Type**: `onSubmit` +- **Script Name**: `Warn Before Closing Without Work Notes` +- **Active**: `true` + +## Script + + +function onSubmit() { + var state = g_form.getValue('state'); + var workNotes = g_form.getValue('work_notes'); + + if ((state == '6' || state == '7') && !workNotes.trim()) { + alert("Please add work notes before resolving or closing the Incident."); + return false; + } + + return true; +} diff --git a/Client-Side Components/Client Scripts/Warn Before Closing Incident Without Work Notes/script.js b/Client-Side Components/Client Scripts/Warn Before Closing Incident Without Work Notes/script.js new file mode 100644 index 0000000000..40b4751222 --- /dev/null +++ b/Client-Side Components/Client Scripts/Warn Before Closing Incident Without Work Notes/script.js @@ -0,0 +1,12 @@ +function onSubmit() { + var state = g_form.getValue('state'); + var workNotes = g_form.getValue('work_notes'); + + // Check if state is Resolved (6) or Closed (7) and work notes are empty + if ((state == '6' || state == '7') && !workNotes.trim()) { + alert("Please add work notes before resolving or closing the Incident."); + return false; // Prevent form submission + } + + return true; // Allow submission +}