AbstractAjaxProcessor Existing-Request Check
Overview
This pattern is a building block for Just-In-Time (JIT) permission requests. These are catalog items that grant temporary, time-limited access and are meant to only ever have one active grant per user at a time. Before the user finishes filling out a new request, it warns them if they already have an active RITM for that same catalog item, so they understand a new submission will override the existing one rather than stack on top of it.
The pattern has two halves:
- A Script Include extending
AbstractAjaxProcessor(marked Client Callable) that queriessc_req_itemfor an active request on a specific catalog item (cat_item) submitted by the current user (requested_for), then looks up a variable’s stored value (likeend_time) via thesc_item_option_mtomjoin table. It returns a small JSON payload describing whether a request exists and its relevant details. - An onLoad Catalog Client Script that calls the Script Include via
GlideAjax, and ifexistscomes backtrue, shows an informational field message warning the user.
A closely related variant extends the same idea to a capacity check rather than a simple existence check: instead of just detecting one active request, it counts how many active requests exist system-wide for the catalog item, and reports max_reached = true once two or more exist. along with the two most recent end_time values, sorted chronologically and joined with “and” for display. This is useful when the restriction is a shared pool limit rather than one-per-user.
Problem Statement
Any catalog item used to grant time-limited access needs a way to enforce one active grant at a time, or a shared limit when access has a limited capacity. Without this check, a user who already has active access could submit another request and unintentionally change their existing expiration time without realizing it.
Showing a warning before the user completes the request helps prevent confusion about why their access may end earlier or later than expected.
Since multiple catalog items need to perform the same sc_req_item and sc_item_option_mtom lookup, that logic is handled in a single Script Include and reused across items. Each catalog item simply passes its own hardcoded catalog item and variable sys_id.
| |