From e651b66a9d580e18ea5c019ea43e40faca4112ae Mon Sep 17 00:00:00 2001 From: Chetna Sharma <146471211+chetnadev@users.noreply.github.com> Date: Thu, 9 Oct 2025 10:01:35 +0530 Subject: [PATCH 1/2] code.js --- .../code.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Server-Side Components/Business Rules/Service Request Submission Throttling/code.js diff --git a/Server-Side Components/Business Rules/Service Request Submission Throttling/code.js b/Server-Side Components/Business Rules/Service Request Submission Throttling/code.js new file mode 100644 index 0000000000..6eecaeb54d --- /dev/null +++ b/Server-Side Components/Business Rules/Service Request Submission Throttling/code.js @@ -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); From 087400944c729b516a3149c916b0f1ad2d461f19 Mon Sep 17 00:00:00 2001 From: Chetna Sharma <146471211+chetnadev@users.noreply.github.com> Date: Thu, 9 Oct 2025 10:06:38 +0530 Subject: [PATCH 2/2] README.md --- .../Service Request Submission Throttling/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Server-Side Components/Business Rules/Service Request Submission Throttling/README.md diff --git a/Server-Side Components/Business Rules/Service Request Submission Throttling/README.md b/Server-Side Components/Business Rules/Service Request Submission Throttling/README.md new file mode 100644 index 0000000000..329c0af811 --- /dev/null +++ b/Server-Side Components/Business Rules/Service Request Submission Throttling/README.md @@ -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.