Skip to content

Commit 70c8cd0

Browse files
Email Template Debugger
1 parent e9cd308 commit 70c8cd0

File tree

3 files changed

+720
-0
lines changed

3 files changed

+720
-0
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Email Template Debugger
2+
3+
## Overview
4+
A powerful utility for ServiceNow developers to debug and preview email notifications in real-time. This tool helps visualize how email templates will render with different data contexts, test notification conditions, and troubleshoot email-related issues without sending actual emails.
5+
6+
## Features
7+
- Live preview of email templates
8+
- Variable substitution testing
9+
- HTML/Plain text toggle view
10+
- Attachment validation
11+
- Template syntax checking
12+
- Recipient list validation
13+
- Condition script testing
14+
- Email script debugging
15+
- Performance metrics
16+
17+
## Requirements
18+
- ServiceNow instance with admin access
19+
- Notification management rights
20+
- Script Include access
21+
- Email administration rights
22+
23+
## Implementation Steps
24+
1. Create a new Script Include using script.js
25+
2. Set up the debugging page using debugger_page.js
26+
3. Configure access controls
27+
4. Import any required style sheets
28+
5. Test with sample notifications
29+
30+
## Components
31+
32+
### Script Include
33+
- Handles template processing
34+
- Manages variable substitution
35+
- Validates email scripts
36+
- Processes attachments
37+
- Checks recipient lists
38+
39+
### Debugging Interface
40+
- Template preview panel
41+
- Variable input section
42+
- Script testing area
43+
- Results display
44+
- Error highlighting
45+
46+
## Usage Example
47+
```javascript
48+
var emailDebugger = new EmailTemplateDebugger();
49+
var result = emailDebugger.debugTemplate({
50+
notificationId: 'sys_id_of_notification',
51+
testRecord: 'sys_id_of_test_record',
52+
recipientList: ['user1@example.com'],
53+
variables: {
54+
'incident.number': 'INC0010001',
55+
'incident.short_description': 'Test incident'
56+
}
57+
});
58+
```
59+
60+
## Features in Detail
61+
62+
### Template Analysis
63+
- Syntax validation
64+
- Missing variable detection
65+
- Script error identification
66+
- HTML structure verification
67+
- CSS compatibility check
68+
69+
### Performance Monitoring
70+
- Template processing time
71+
- Script execution metrics
72+
- Database query impact
73+
- Attachment processing time
74+
- Overall generation time
75+
76+
### Security Checks
77+
- Recipient validation
78+
- Domain verification
79+
- Script injection prevention
80+
- Attachment size validation
81+
- Permission verification
82+
83+
### Debugging Tools
84+
- Step-by-step template processing
85+
- Variable resolution tracking
86+
- Script execution logging
87+
- Error stack traces
88+
- Query optimization hints
89+
90+
## Best Practices
91+
1. Always test with sample data first
92+
2. Verify all variable substitutions
93+
3. Check both HTML and plain text versions
94+
4. Validate attachment handling
95+
5. Test with different record types
96+
6. Monitor performance metrics
97+
7. Review security implications
98+
99+
## Error Handling
100+
The debugger provides detailed error information for:
101+
- Syntax errors in templates
102+
- Missing or invalid variables
103+
- Script execution failures
104+
- Recipient list issues
105+
- Attachment problems
106+
- Permission errors
107+
108+
## Performance Considerations
109+
- Cache frequently used templates
110+
- Optimize script execution
111+
- Batch process attachments
112+
- Minimize database queries
113+
- Use efficient variable substitution
114+
115+
## Security Notes
116+
- Validate all input data
117+
- Check recipient permissions
118+
- Sanitize variable content
119+
- Verify attachment types
120+
- Monitor script execution
121+
122+
## Troubleshooting
123+
Common issues and solutions:
124+
1. Template not found
125+
- Verify notification sys_id
126+
- Check access permissions
127+
2. Variable substitution fails
128+
- Confirm variable names
129+
- Check data types
130+
3. Script errors
131+
- Review script syntax
132+
- Check variable scope
133+
4. Attachment issues
134+
- Verify file permissions
135+
- Check size limits
136+
137+
## Extensions
138+
The debugger can be extended with:
139+
- Custom validation rules
140+
- Additional preview formats
141+
- New debugging tools
142+
- Performance analyzers
143+
- Security checkers

0 commit comments

Comments
 (0)