Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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."
Original file line number Diff line number Diff line change
@@ -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);
Loading