Create business rules with before/after/async triggers and conditions
✓Works with OpenClaudeYou are a ServiceNow platform expert. The user wants to create and deploy business rules with before/after/async triggers and conditions to automate table operations.
What to check first
- Navigate to System Definition > Business Rules in your ServiceNow instance to see existing rules
- Verify your user role includes
adminorbusiness_rule_adminfor rule creation - Check the target table schema in System Definition > Tables to understand field names and types
Steps
- Open System Definition > Business Rules and click New to create a business rule record
- Set the Name field to a descriptive identifier (e.g., "Set incident priority on create")
- Select the Table dropdown and choose your target table (e.g.,
incident,change_request) - Under When to run, choose the trigger type:
- Before — runs before database insert/update (use for validation/field population)
- After — runs after commit (use for notifications, downstream updates)
- Async — runs asynchronously after commit (use for heavy operations)
- Set Insert, Update, or both checkboxes depending on when the rule fires
- In the Condition tab, build your filter conditions (e.g.,
Priority is emptyANDUrgency is 1) - In the Advanced tab, write your business logic in the Script field using GlideRecord API
- Click Submit to activate the business rule
Code
// ServiceNow Business Rule Script - Incident Priority Auto-Assignment
// Condition: Before Insert/Update | Priority is empty | Urgency = 1
// Access current record via 'current' object (built-in GlideRecord)
if (current.priority.isEmpty()) {
// Set priority based on urgency
if (current.urgency.getValue() === '1') {
current.priority = '1'; // Critical
} else if (current.urgency.getValue() === '2') {
current.priority = '2'; // High
} else {
current.priority = '3'; // Medium
}
}
// Optionally add a comment to the ticket
current.comments.setDisplayValue('Priority auto-assigned based on urgency');
// For AFTER business rules, use gs.info() or gs.warn() for logging
gs.info('Incident priority set to ' + current.priority.getDisplayValue());
// For ASYNC rules, use GlideRecord queries for downstream operations
var grChange = new GlideRecord('change_request');
grChange.addQuery('related_incident', current.sys_id);
grChange.query();
while (grChange.next()) {
grChange.priority = current.priority;
grChange.setWorkflow(false); // Prevent recursive business rule triggers
grChange.update();
}
// Trigger event for external integration (optional)
gs.eventQueue('incident.priority.updated', current, current.
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related ServiceNow Skills
Other Claude Code skills in the same category — free to download.
ServiceNow Scripted REST
Build Scripted REST APIs with request/response handling
ServiceNow Flow Designer
Build automated workflows with Flow Designer actions and subflows
ServiceNow Client Script
Write client scripts for form manipulation (onChange, onLoad, onSubmit)
ServiceNow Catalog Item
Build service catalog items with variables, workflows, and fulfillment
ServiceNow Integration Hub
Connect ServiceNow with external systems using IntegrationHub spokes
ServiceNow ATF Testing
Write automated tests with Automated Test Framework
ServiceNow UI Builder
Build custom portal pages with UI Builder and components
ServiceNow CMDB
Configure CMDB with CI classes, relationships, and discovery
Want a ServiceNow skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.