Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#145 This request definitely made me pause and think through some important questions—such as who gets access to this, what privilege level the scripts run at, whether it opens doors for ACL bypasses, and how it aligns with compliance requirements like SOX or PCI-DSS. But honestly, the technical puzzle was interesting enough that I decided to dig into it anyway.
Implementation Challenge:
Turns out ServiceNow's JavaScript APIs make this trickier than expected. The eval() function only works in global scope, and GlideScopedEvaluator (which would be the "proper" scoped option) needs you to save the script to a GlideRecord first before it can run anything. There's no clean way to just execute a script string from memory in a scoped app—you either have to persist it to a table or work in global scope, and both of those options bring their own security headaches.
Solution Implemented:
I ended up building the custom action with a flexible approach that uses a temporary table to handle the GlideScopedEvaluator requirement:
Input Variables (6 total):
Output Variables (4 total):
This way, you get audit trails and execution metadata while working within ServiceNow's scoped API constraints.
Example (minimal):
Example (with custom audit field names):
Note: Logs will show the triggering user (from Flow context), but scripts execute in system context due to GlideScopedEvaluator isolation. The audit fields (if configured) capture the actual triggering user before execution.