BeanShell examples
Quick answer
These BeanShell examples show common scripting patterns, logging, attribute access and helper calls, used inside rules and workflows.
Key takeaways
- Logging and debugging
- Attribute access
- Calling helper methods
- Keep snippets side-effect-light
BeanShell is the scripting language used throughout IdentityIQ rules and workflows. These snippets show everyday patterns that keep custom logic debuggable and robust.
Logging for debugging
import org.apache.log4j.Logger;
Logger log = Logger.getLogger("custom.myrule");
log.debug("Processing: " + (identity != null ? identity.getName() : "null"));Safe attribute access
String dept = identity != null ? identity.getStringAttribute("department") : null;
if (dept == null) { dept = "UNKNOWN"; }Guidance
- Log at debug with a named logger to trace values without production noise.
- Guard every dereference, BeanShell throws at runtime otherwise.
- Keep snippets side-effect-light, they often run per identity.
Common pitfalls
- No logging, leaving failures opaque.
- Null-pointer errors from unguarded access.
- Expensive work in per-identity snippets.
Want to learn this properly?
Our live, instructor-led SailPoint Training covers this hands-on, with real projects and a certification path.
Check your understanding
What is BeanShell used for?
- A. Use logging (log4j Logger) to trace values.
- B. Scripting logic inside IdentityIQ rules and workflows.
- C. Heavy side effects that hurt performance.
Show answer
B. Scripting logic inside IdentityIQ rules and workflows.
Scripting logic inside IdentityIQ rules and workflows.
How do you debug BeanShell?
- A. Use logging (log4j Logger) to trace values.
- B. Heavy side effects that hurt performance.
- C. Scripting logic inside IdentityIQ rules and workflows.
Show answer
A. Use logging (log4j Logger) to trace values.
Use logging (log4j Logger) to trace values.
What should snippets avoid?
- A. Use logging (log4j Logger) to trace values.
- B. Heavy side effects that hurt performance.
- C. Scripting logic inside IdentityIQ rules and workflows.
Show answer
B. Heavy side effects that hurt performance.
Heavy side effects that hurt performance.