From 89475ec455f3970a06493562a5b8346e54876abc Mon Sep 17 00:00:00 2001 From: Indra-kolge <123245160+Indra-kolge@users.noreply.github.com> Date: Sat, 18 Oct 2025 20:48:25 +0530 Subject: [PATCH 1/2] script.js --- .../script.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Server-Side Components/Business Rules/Prevent Duplicate Incident submission/script.js diff --git a/Server-Side Components/Business Rules/Prevent Duplicate Incident submission/script.js b/Server-Side Components/Business Rules/Prevent Duplicate Incident submission/script.js new file mode 100644 index 0000000000..cf644bf59d --- /dev/null +++ b/Server-Side Components/Business Rules/Prevent Duplicate Incident submission/script.js @@ -0,0 +1,22 @@ +(function executeRule(current, previous /*null when async*/) { + var dup = new GlideRecord('incident'); + dup.addQuery('caller_id', current.caller_id); + dup.addQuery('short_description', current.short_description); + dup.addQuery('state', '!=', 6); // Exclude closed + var sevenDaysAgo = new GlideDateTime(); + sevenDaysAgo.addDaysUTC(-7); + dup.addQuery('sys_created_on', '>=', sevenDaysAgo); + dup.query(); + + if (dup.next()) { + // Build URL dynamically based on instance name + var instanceName = gs.getProperty('instance_name'); + var url = gs.getProperty('glide.servlet.uri') + 'incident.do?sys_id=' + dup.sys_id; + + // Add info message with hyperlink + gs.addInfoMessage("A similar incident " + dup.number + " already exists (created within the last 7 days)."); + + // Stop creation of duplicate + current.setAbortAction(true); + } +})(current, previous); From dd231417461b1aaa148c6a95d76773d8acd5da6b Mon Sep 17 00:00:00 2001 From: Indra-kolge <123245160+Indra-kolge@users.noreply.github.com> Date: Sat, 18 Oct 2025 20:54:07 +0530 Subject: [PATCH 2/2] README.md --- .../Prevent Duplicate Incident submission/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Server-Side Components/Business Rules/Prevent Duplicate Incident submission/README.md diff --git a/Server-Side Components/Business Rules/Prevent Duplicate Incident submission/README.md b/Server-Side Components/Business Rules/Prevent Duplicate Incident submission/README.md new file mode 100644 index 0000000000..c1d50f3576 --- /dev/null +++ b/Server-Side Components/Business Rules/Prevent Duplicate Incident submission/README.md @@ -0,0 +1,11 @@ +Table: Incident +When to run : On Before Insert + +Use case: + +This Business rule prevents users from creating duplicate incidents. Its checks last 7 days open incident with same caller and short description. +When a user tries to create an incident with the same short description and caller, the system: + Stops the new record from being created. + Displays an info message with a clickable link to the existing incident. + +This helps reduce incident clutter and ensures users track existing issues instead of repeatedly logging new ones.