Script Body Guide (Groovy Java)
This page explains how to write the Script Body for an Alert Script. The script runs server-side and synchronously when the trigger event fires (Create / Update / Delete).
1) Script Body rules (must-follow)
2) Runtime variables (available without declaration)
Core context
Message output
3) Recommended structure (copy-paste mental model)
4) Type check + casting (avoid ClassCastException)
5) Null-Safety: Patterns and Best Practices
6) Field access and status comparisons
Linked object navigation
Status fields
7) Update/change detection (current vs old)
Step-by-step pattern
Null-safe comparisons
Numeric thresholds (example)
8) Message building modes (CRITICAL – prevents misconfiguration)
Mode A — Build message in script = true
Mode B — Build message in script = false
The broken combo
9) Guidance for generators / validation logic (recommended)
10) Optional: fetching related data (advanced)
11) Troubleshooting
Logging
Return-path sanity
12) Full example (safe, readable, and template-based)
Was this helpful?