How to cache data in a "Before Query" Business Rule and use it in "Read" ACL?

DaQQF
Tera Contributor

Hi,

 

Direct sharing of variables between Business Rules and ACLs is not supported because they run in separate script contexts.

Is there good way to cache data in a "Before Query" Business Rule and use it in "Read" ACL?

 

AI:

In ServiceNow, caching data in a "Before Query" Business Rule and reusing it in a "Read" ACL (not "Before Read") follows a similar logic to the "Before Read" scenario but with key differences in timing and context. Here’s how to do it effectively:

Key Context: How "Read" ACLs Differ from "Before Read"

  • A "Read" ACL (often called a "standard Read ACL") runs after the record is fetched (post-query) to determine if the user can view the record. It uses the current object (the fetched record) and answer to grant/deny access.
  • A "Before Query" Business Rule runs before the database query executes, filtering which records are fetched in the first place.
Data cached in the "Before Query" rule must persist through the query execution and into the "Read" ACL’s execution (same transaction).


If there’s no other way to achieve this, I’ll have to create a custom table and set up a scheduled task to check for expirations.



0 REPLIES 0