From f9bed92ce43e62f5bc9981750fe84a020163e0b5 Mon Sep 17 00:00:00 2001 From: Chetna Sharma <146471211+chetnadev@users.noreply.github.com> Date: Wed, 8 Oct 2025 23:37:50 +0530 Subject: [PATCH 1/2] Create code.js --- .../code.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Server-Side Components/Business Rules/Automatically Throttle Incidents Raised by Same User Within Short Timeframe/code.js diff --git a/Server-Side Components/Business Rules/Automatically Throttle Incidents Raised by Same User Within Short Timeframe/code.js b/Server-Side Components/Business Rules/Automatically Throttle Incidents Raised by Same User Within Short Timeframe/code.js new file mode 100644 index 0000000000..41913d1981 --- /dev/null +++ b/Server-Side Components/Business Rules/Automatically Throttle Incidents Raised by Same User Within Short Timeframe/code.js @@ -0,0 +1,26 @@ +(function executeRule(current, gsn, gs) { + + var limit = 3; + var windowMins = 10; + + var recentIncidents = new GlideRecord('incident'); + recentIncidents.addQuery('caller_id', current.caller_id); + + var now = new GlideDateTime(); + var cutoff = new GlideDateTime(); + cutoff.addMinutes(-windowMins); + + recentIncidents.addQuery('sys_created_on', '>=', cutoff); + recentIncidents.query(); + + var count = 0; + while (recentIncidents.next()) { + count++; + } + + if (count >= limit) { + gs.addErrorMessage("You have submitted too many incidents in a short time. Please wait before submitting more."); + current.setAbortAction(true); + } + +})(current, gsn, gs); From 25443c8356efdb03e1fb00b09135d5657790316c Mon Sep 17 00:00:00 2001 From: Chetna Sharma <146471211+chetnadev@users.noreply.github.com> Date: Wed, 8 Oct 2025 23:39:14 +0530 Subject: [PATCH 2/2] Create README.md --- .../README.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Server-Side Components/Business Rules/Automatically Throttle Incidents Raised by Same User Within Short Timeframe/README.md diff --git a/Server-Side Components/Business Rules/Automatically Throttle Incidents Raised by Same User Within Short Timeframe/README.md b/Server-Side Components/Business Rules/Automatically Throttle Incidents Raised by Same User Within Short Timeframe/README.md new file mode 100644 index 0000000000..5f4567784c --- /dev/null +++ b/Server-Side Components/Business Rules/Automatically Throttle Incidents Raised by Same User Within Short Timeframe/README.md @@ -0,0 +1,8 @@ +This business rule prevents users from submitting too many incidents in a short time, acting as a rate-limiting mechanism to reduce spam or misuse of the incident form. + +What It Does: +-Checks how many incidents the same caller has submitted in the last 10 minutes. +-If the number of incidents is 3 or more, the rule: +-Blocks the current incident from being submitted. +-Displays an error message: +"You have submitted too many incidents in a short time. Please wait before submitting more."