Skip to content
Closed
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,9 @@
This business rule in ServiceNow is designed to limit the number of service catalog requests a user can submit within a certain timeframe — specifically, 5 requests per hour.

This rule helps throttle excessive catalog request submissions, which can:
Prevent system abuse (intentional or accidental),
Avoid spamming by users (especially in large environments)

This ServiceNow Business Rule checks if the current user has submitted 5 or more service catalog requests (sc_request) in the past hour. If they have:
It shows an error message, And aborts the current request from being submitted.
It uses GlideAggregate to efficiently count recent requests made by the same user, and compares the count against the limit.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(function executeRule(current, gsn, gs) {
var user = gs.getUserID();
var windowStart = new GlideDateTime();
windowStart.addHours(-1);

var gr = new GlideAggregate('sc_request');
gr.addQuery('requested_for', user);
gr.addQuery('sys_created_on', '>=', windowStart);
gr.addAggregate('COUNT');
gr.query();

if (gr.next() && parseInt(gr.getAggregate('COUNT')) >= 5) {
gs.addErrorMessage("You have reached the request submission limit. Please wait and try again later.");
current.setAbortAction(true);
}
})(current, gsn, gs);
Loading