servicenow-mcp-server 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +70 -0
- package/CLAUDE.md +777 -0
- package/LICENSE +21 -0
- package/README.md +562 -0
- package/assets/logo.svg +385 -0
- package/config/servicenow-instances.json.example +28 -0
- package/docs/403_TROUBLESHOOTING.md +329 -0
- package/docs/API_REFERENCE.md +1142 -0
- package/docs/APPLICATION_SCOPE_VALIDATION.md +681 -0
- package/docs/CLAUDE_DESKTOP_SETUP.md +373 -0
- package/docs/CONVENIENCE_TOOLS.md +601 -0
- package/docs/CONVENIENCE_TOOLS_SUMMARY.md +371 -0
- package/docs/FLOW_DESIGNER_GUIDE.md +1021 -0
- package/docs/IMPLEMENTATION_COMPLETE.md +165 -0
- package/docs/INSTANCE_SWITCHING_GUIDE.md +219 -0
- package/docs/MULTI_INSTANCE_CONFIGURATION.md +185 -0
- package/docs/NATURAL_LANGUAGE_SEARCH_IMPLEMENTATION.md +221 -0
- package/docs/PUPPETEER_INTEGRATION_PROPOSAL.md +1322 -0
- package/docs/QUICK_REFERENCE.md +395 -0
- package/docs/README.md +75 -0
- package/docs/RESOURCES_ARCHITECTURE.md +392 -0
- package/docs/RESOURCES_IMPLEMENTATION.md +276 -0
- package/docs/RESOURCES_SUMMARY.md +104 -0
- package/docs/SETUP_GUIDE.md +104 -0
- package/docs/UI_OPERATIONS_ARCHITECTURE.md +1219 -0
- package/docs/UI_OPERATIONS_DECISION_MATRIX.md +542 -0
- package/docs/UI_OPERATIONS_SUMMARY.md +507 -0
- package/docs/UPDATE_SET_VALIDATION.md +598 -0
- package/docs/UPDATE_SET_VALIDATION_SUMMARY.md +209 -0
- package/docs/VALIDATION_SUMMARY.md +479 -0
- package/jest.config.js +24 -0
- package/package.json +61 -0
- package/scripts/background_script_2025-09-29T20-19-35-101Z.js +23 -0
- package/scripts/link_ui_policy_actions_2025-09-29T20-17-15-218Z.js +90 -0
- package/scripts/set_update_set_Integration_Governance_Framework_2025-09-29T19-47-06-790Z.js +30 -0
- package/scripts/set_update_set_Integration_Governance_Framework_2025-09-29T19-59-33-152Z.js +30 -0
- package/scripts/set_update_set_current_2025-09-29T20-16-59-675Z.js +24 -0
- package/scripts/test_sys_dictionary_403.js +85 -0
- package/setup/setup-report.json +5313 -0
- package/src/config/comprehensive-table-definitions.json +2575 -0
- package/src/config/instance-config.json +4693 -0
- package/src/config/prompts.md +59 -0
- package/src/config/table-definitions.json +4681 -0
- package/src/config-manager.js +146 -0
- package/src/mcp-server-consolidated.js +2894 -0
- package/src/natural-language.js +472 -0
- package/src/resources.js +326 -0
- package/src/script-sync.js +428 -0
- package/src/server.js +125 -0
- package/src/servicenow-client.js +1625 -0
- package/src/stdio-server.js +52 -0
- package/start-mcp.sh +7 -0
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
# UI Operations Decision Matrix
|
|
2
|
+
|
|
3
|
+
**Version:** 1.0
|
|
4
|
+
**Date:** 2025-10-06
|
|
5
|
+
**Purpose:** Quick reference for choosing the right approach for ServiceNow operations
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Decision Tree
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Need to perform ServiceNow operation?
|
|
13
|
+
↓
|
|
14
|
+
┌───────┴───────┐
|
|
15
|
+
│ │
|
|
16
|
+
Is it CRUD? Is it Config?
|
|
17
|
+
│ │
|
|
18
|
+
↓ ↓
|
|
19
|
+
Use REST API Is it in update set?
|
|
20
|
+
✅ SN-Query-Table │
|
|
21
|
+
✅ SN-Create-Record ↓
|
|
22
|
+
✅ SN-Update-Record ┌────┴────┐
|
|
23
|
+
│ │
|
|
24
|
+
Workflow? Flow?
|
|
25
|
+
│ │
|
|
26
|
+
↓ ↓
|
|
27
|
+
✅ Automate ⚠️ Manual
|
|
28
|
+
via MCP + Export
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Operation Category Matrix
|
|
34
|
+
|
|
35
|
+
### CRUD Operations (100% Automated) ✅
|
|
36
|
+
|
|
37
|
+
| Operation | Use This | Performance | Example |
|
|
38
|
+
|-----------|----------|-------------|---------|
|
|
39
|
+
| **Query records** | `SN-Query-Table` | <1s | List incidents |
|
|
40
|
+
| **Create record** | `SN-Create-Record` | <1s | Create incident |
|
|
41
|
+
| **Read record** | `SN-Get-Record` | <1s | Get incident details |
|
|
42
|
+
| **Update record** | `SN-Update-Record` | <1s | Resolve incident |
|
|
43
|
+
| **Batch create** | `SN-Batch-Create` | 2-5s | Create 10+ records |
|
|
44
|
+
| **Batch update** | `SN-Batch-Update` | 2-5s | Update 43+ records |
|
|
45
|
+
|
|
46
|
+
**When to Use:** Always for data operations
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### Configuration Management (100% Automated) ✅
|
|
51
|
+
|
|
52
|
+
| Operation | Use This | Performance | Example |
|
|
53
|
+
|-----------|----------|-------------|---------|
|
|
54
|
+
| **Set update set** | `SN-Set-Update-Set` | ~2s | Switch to dev set |
|
|
55
|
+
| **Set app scope** | `SN-Set-Current-Application` | ~2s | Switch to scoped app |
|
|
56
|
+
| **Get current set** | `SN-Get-Current-Update-Set` | <1s | Verify current set |
|
|
57
|
+
| **Move records** | `SN-Move-Records-To-Update-Set` | 2-5s | Fix wrong set |
|
|
58
|
+
| **Clone set** | `SN-Clone-Update-Set` | <1s | Backup update set |
|
|
59
|
+
| **Inspect set** | `SN-Inspect-Update-Set` | <1s | View set contents |
|
|
60
|
+
|
|
61
|
+
**When to Use:** Always before making config changes
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### Workflow Operations (100% Automated) ✅
|
|
66
|
+
|
|
67
|
+
| Operation | Use This | Performance | Example |
|
|
68
|
+
|-----------|----------|-------------|---------|
|
|
69
|
+
| **Create workflow** | `SN-Create-Workflow` | <1s | Auto-approval workflow |
|
|
70
|
+
| **Add activity** | `SN-Create-Activity` | <1s | Notification step |
|
|
71
|
+
| **Link activities** | `SN-Create-Transition` | <1s | Connect steps |
|
|
72
|
+
| **Publish workflow** | `SN-Publish-Workflow` | <1s | Make workflow live |
|
|
73
|
+
|
|
74
|
+
**When to Use:** When you need programmatic workflow creation
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### Flow Designer (20% Automated) ⚠️
|
|
79
|
+
|
|
80
|
+
| Operation | Use This | Performance | Notes |
|
|
81
|
+
|-----------|----------|-------------|-------|
|
|
82
|
+
| **Create flow** | ❌ Manual UI | Manual | Cannot automate |
|
|
83
|
+
| **Execute flow** | `FlowAPI` via script | <1s | ✅ Fully automated |
|
|
84
|
+
| **Modify flow** | ❌ Manual UI | Manual | Cannot automate |
|
|
85
|
+
| **Export flow** | Update set | Manual | Via UI |
|
|
86
|
+
| **Import flow** | Update set | Manual | Via UI |
|
|
87
|
+
|
|
88
|
+
**When to Use:**
|
|
89
|
+
- Create flows manually in UI (one-time)
|
|
90
|
+
- Execute flows programmatically via MCP (many times)
|
|
91
|
+
- See: `docs/FLOW_DESIGNER_GUIDE.md`
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### Background Scripts (100% Automated) ✅
|
|
96
|
+
|
|
97
|
+
| Operation | Use This | Performance | Example |
|
|
98
|
+
|-----------|----------|-------------|---------|
|
|
99
|
+
| **Execute script** | `SN-Execute-Background-Script` | ~1s | Complex GlideRecord |
|
|
100
|
+
| **UI Policy linking** | Background script | ~1s | Link policy actions |
|
|
101
|
+
| **Complex queries** | Background script | 1-2s | Advanced filtering |
|
|
102
|
+
| **Data migration** | Background script | 1-5s | Bulk data updates |
|
|
103
|
+
|
|
104
|
+
**When to Use:**
|
|
105
|
+
- Operations not available via REST API
|
|
106
|
+
- Complex GlideRecord operations
|
|
107
|
+
- UI Policy Actions linking
|
|
108
|
+
|
|
109
|
+
**Method:** sys_trigger (automated, ~1 second)
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Decision Matrix by Use Case
|
|
114
|
+
|
|
115
|
+
### Use Case 1: Create and Deploy Configuration
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
┌─────────────────────────────────────────────────┐
|
|
119
|
+
│ Goal: Create table field, deploy to prod │
|
|
120
|
+
├─────────────────────────────────────────────────┤
|
|
121
|
+
│ 1. Set update set │
|
|
122
|
+
│ ✅ SN-Set-Update-Set (automated, ~2s) │
|
|
123
|
+
│ │
|
|
124
|
+
│ 2. Create field via REST API │
|
|
125
|
+
│ ✅ SN-Create-Record (automated, <1s) │
|
|
126
|
+
│ table: sys_dictionary │
|
|
127
|
+
│ │
|
|
128
|
+
│ 3. Verify captured in set │
|
|
129
|
+
│ ✅ SN-Inspect-Update-Set (automated, <1s) │
|
|
130
|
+
│ │
|
|
131
|
+
│ 4. Export update set │
|
|
132
|
+
│ ⚠️ Manual: UI → Export XML │
|
|
133
|
+
│ │
|
|
134
|
+
│ 5. Import to prod │
|
|
135
|
+
│ ⚠️ Manual: UI → Import XML │
|
|
136
|
+
├─────────────────────────────────────────────────┤
|
|
137
|
+
│ Automation: 80% (3/5 steps) │
|
|
138
|
+
│ Time: ~3 seconds automated + 2 minutes manual │
|
|
139
|
+
└─────────────────────────────────────────────────┘
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Verdict:** ✅ Good automation, acceptable manual steps
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### Use Case 2: Create Workflow
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
┌─────────────────────────────────────────────────┐
|
|
150
|
+
│ Goal: Create approval workflow │
|
|
151
|
+
├─────────────────────────────────────────────────┤
|
|
152
|
+
│ 1. Set update set │
|
|
153
|
+
│ ✅ SN-Set-Update-Set (automated, ~2s) │
|
|
154
|
+
│ │
|
|
155
|
+
│ 2. Create workflow │
|
|
156
|
+
│ ✅ SN-Create-Workflow (automated, <1s) │
|
|
157
|
+
│ - Define activities │
|
|
158
|
+
│ - Define transitions │
|
|
159
|
+
│ - Set conditions │
|
|
160
|
+
│ │
|
|
161
|
+
│ 3. Publish workflow │
|
|
162
|
+
│ ✅ SN-Publish-Workflow (automated, <1s) │
|
|
163
|
+
│ │
|
|
164
|
+
│ 4. Export update set │
|
|
165
|
+
│ ⚠️ Manual: UI → Export XML │
|
|
166
|
+
├─────────────────────────────────────────────────┤
|
|
167
|
+
│ Automation: 100% (creation), 75% (deployment) │
|
|
168
|
+
│ Time: ~3 seconds automated + 1 minute manual │
|
|
169
|
+
└─────────────────────────────────────────────────┘
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Verdict:** ✅ Excellent automation
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
### Use Case 3: Create Flow Designer Flow
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
┌─────────────────────────────────────────────────┐
|
|
180
|
+
│ Goal: Create incident auto-assignment flow │
|
|
181
|
+
├─────────────────────────────────────────────────┤
|
|
182
|
+
│ 1. Set update set │
|
|
183
|
+
│ ✅ SN-Set-Update-Set (automated, ~2s) │
|
|
184
|
+
│ │
|
|
185
|
+
│ 2. Create flow │
|
|
186
|
+
│ ❌ Manual: Flow Designer UI │
|
|
187
|
+
│ - Define trigger │
|
|
188
|
+
│ - Add actions │
|
|
189
|
+
│ - Add conditions │
|
|
190
|
+
│ - Test flow │
|
|
191
|
+
│ - Activate flow │
|
|
192
|
+
│ Time: 10-30 minutes │
|
|
193
|
+
│ │
|
|
194
|
+
│ 3. Export update set │
|
|
195
|
+
│ ⚠️ Manual: UI → Export XML │
|
|
196
|
+
│ │
|
|
197
|
+
│ 4. Import to other envs │
|
|
198
|
+
│ ⚠️ Manual: UI → Import XML │
|
|
199
|
+
│ │
|
|
200
|
+
│ 5. Execute flow (ongoing) │
|
|
201
|
+
│ ✅ FlowAPI via script (automated, <1s) │
|
|
202
|
+
├─────────────────────────────────────────────────┤
|
|
203
|
+
│ Automation: 20% (creation), 100% (execution) │
|
|
204
|
+
│ Time: One-time 10-30 min + automated runtime │
|
|
205
|
+
└─────────────────────────────────────────────────┘
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Verdict:** ⚠️ Acceptable (one-time manual, ongoing automated)
|
|
209
|
+
|
|
210
|
+
**Alternative:** Use workflows instead if programmatic creation needed
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
### Use Case 4: Manage Update Sets
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
┌─────────────────────────────────────────────────┐
|
|
218
|
+
│ Goal: Fix records in wrong update set │
|
|
219
|
+
├─────────────────────────────────────────────────┤
|
|
220
|
+
│ 1. Query records in wrong set │
|
|
221
|
+
│ ✅ SN-Query-Table (automated, <1s) │
|
|
222
|
+
│ table: sys_update_xml │
|
|
223
|
+
│ query: update_set=<wrong_set_id> │
|
|
224
|
+
│ │
|
|
225
|
+
│ 2. Move records to correct set │
|
|
226
|
+
│ ✅ SN-Batch-Update (automated, 2-5s) │
|
|
227
|
+
│ - 43+ records tested successfully │
|
|
228
|
+
│ │
|
|
229
|
+
│ 3. Verify move │
|
|
230
|
+
│ ✅ SN-Query-Table (automated, <1s) │
|
|
231
|
+
│ query: update_set=<correct_set_id> │
|
|
232
|
+
├─────────────────────────────────────────────────┤
|
|
233
|
+
│ Automation: 100% │
|
|
234
|
+
│ Time: 3-6 seconds total │
|
|
235
|
+
└─────────────────────────────────────────────────┘
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Verdict:** ✅ Excellent automation
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
### Use Case 5: Link UI Policy Actions
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
┌─────────────────────────────────────────────────┐
|
|
246
|
+
│ Goal: Link catalog variable to UI policy │
|
|
247
|
+
├─────────────────────────────────────────────────┤
|
|
248
|
+
│ 1. Create UI policy via REST │
|
|
249
|
+
│ ✅ SN-Create-Record (automated, <1s) │
|
|
250
|
+
│ table: catalog_ui_policy │
|
|
251
|
+
│ │
|
|
252
|
+
│ 2. Create UI policy action via REST │
|
|
253
|
+
│ ✅ SN-Create-Record (automated, <1s) │
|
|
254
|
+
│ table: catalog_ui_policy_action │
|
|
255
|
+
│ ⚠️ Fields ui_policy, catalog_variable │
|
|
256
|
+
│ cannot be set via REST │
|
|
257
|
+
│ │
|
|
258
|
+
│ 3. Link action to policy via script │
|
|
259
|
+
│ ✅ SN-Execute-Background-Script (~1s) │
|
|
260
|
+
│ Uses setValue() to link │
|
|
261
|
+
│ format: IO:<variable_sys_id> │
|
|
262
|
+
│ │
|
|
263
|
+
│ 4. Verify linkage │
|
|
264
|
+
│ ✅ SN-Get-Record (automated, <1s) │
|
|
265
|
+
├─────────────────────────────────────────────────┤
|
|
266
|
+
│ Automation: 100% │
|
|
267
|
+
│ Time: ~3 seconds total │
|
|
268
|
+
└─────────────────────────────────────────────────┘
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Verdict:** ✅ Excellent automation (workaround successful)
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Performance Comparison
|
|
276
|
+
|
|
277
|
+
### Operation Speed by Method
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
REST API: ▓ 0.8s
|
|
281
|
+
UI API Endpoints: ▓▓ 1.8s
|
|
282
|
+
Background Script: ▓ 1.2s
|
|
283
|
+
Batch Operations (10): ▓▓ 2.1s
|
|
284
|
+
Batch Operations (43): ▓▓▓▓ 4.8s
|
|
285
|
+
Manual UI (simple): ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 30s
|
|
286
|
+
Manual UI (flow): ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 600s
|
|
287
|
+
Puppeteer (if impl): ▓▓▓▓▓▓▓▓▓▓ 20s
|
|
288
|
+
|
|
289
|
+
Legend: ▓ = 2 seconds
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Conclusion:** Automated methods are 10-100x faster than manual UI
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Reliability Comparison
|
|
297
|
+
|
|
298
|
+
### Success Rate by Method
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
REST API: ████████████ 99.9%
|
|
302
|
+
UI API Endpoints: ███████████░ 99.5%
|
|
303
|
+
Background Scripts: ██████████░░ 99.0%
|
|
304
|
+
Batch Operations: █████████░░░ 98.0%
|
|
305
|
+
Manual UI: ████████████ 99.9% (but slow)
|
|
306
|
+
Puppeteer (if impl): ████░░░░░░░░ 70-80% (brittle)
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**Conclusion:** Current automated methods are highly reliable
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## Maintenance Burden
|
|
314
|
+
|
|
315
|
+
### Development & Ongoing Maintenance
|
|
316
|
+
|
|
317
|
+
| Method | Initial Dev | Ongoing Maintenance | Complexity |
|
|
318
|
+
|--------|-------------|---------------------|------------|
|
|
319
|
+
| **REST API** | 1x | 0.1x | Low |
|
|
320
|
+
| **UI Endpoints** | 2x | 0.2x | Low |
|
|
321
|
+
| **Background Scripts** | 2x | 0.3x | Medium |
|
|
322
|
+
| **Manual UI** | 0x | 0x | None |
|
|
323
|
+
| **Puppeteer** | 10x | 5x | Very High |
|
|
324
|
+
|
|
325
|
+
**Legend:** x = baseline effort unit (e.g., 1 hour)
|
|
326
|
+
|
|
327
|
+
**Conclusion:** Puppeteer maintenance burden is 20-50x higher
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## ROI Analysis
|
|
332
|
+
|
|
333
|
+
### Return on Investment by Approach
|
|
334
|
+
|
|
335
|
+
```
|
|
336
|
+
Current (Hybrid):
|
|
337
|
+
Coverage: 95%
|
|
338
|
+
Effort: 100 hours (done)
|
|
339
|
+
ROI: ████████████ Excellent
|
|
340
|
+
|
|
341
|
+
Puppeteer Addition:
|
|
342
|
+
Coverage: +2% (to 97%)
|
|
343
|
+
Effort: 80 hours (new) + 20 hours/year (maintenance)
|
|
344
|
+
ROI: ░░░░░░░░░░░░ Very Poor
|
|
345
|
+
|
|
346
|
+
Additional Documentation:
|
|
347
|
+
Coverage: 0% (but better UX)
|
|
348
|
+
Effort: 7 hours
|
|
349
|
+
ROI: ████████░░░░ Good
|
|
350
|
+
|
|
351
|
+
Flow Templates:
|
|
352
|
+
Coverage: 0% (but faster dev)
|
|
353
|
+
Effort: 4 hours
|
|
354
|
+
ROI: ██████░░░░░░ Fair
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
**Conclusion:** Current approach has excellent ROI, Puppeteer has poor ROI
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## When to Choose Each Approach
|
|
362
|
+
|
|
363
|
+
### Decision Table
|
|
364
|
+
|
|
365
|
+
| If You Need To... | Use This Approach | Reason |
|
|
366
|
+
|-------------------|-------------------|--------|
|
|
367
|
+
| Query data | REST API | Fast, reliable, native |
|
|
368
|
+
| Create records | REST API | Fast, reliable, native |
|
|
369
|
+
| Update records | REST API | Fast, reliable, native |
|
|
370
|
+
| Set update set | UI API endpoint | Automated, proven |
|
|
371
|
+
| Set app scope | UI API endpoint | Automated, proven |
|
|
372
|
+
| Create workflow | REST API | Fully automated |
|
|
373
|
+
| Execute flow | FlowAPI | Fully automated |
|
|
374
|
+
| Create flow | Manual UI + export | Only option, one-time effort |
|
|
375
|
+
| Link UI policy | Background script | Workaround for REST limit |
|
|
376
|
+
| Complex GlideRecord | Background script | Server-side APIs needed |
|
|
377
|
+
| Batch operations | REST API parallel | Fast, efficient |
|
|
378
|
+
| Visual UI config | Manual UI | No automation available |
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## Common Pitfalls to Avoid
|
|
383
|
+
|
|
384
|
+
### ❌ Don't Do This
|
|
385
|
+
|
|
386
|
+
**1. Try to Automate Flow Designer Creation**
|
|
387
|
+
- ❌ Complex undocumented JSON
|
|
388
|
+
- ❌ 15+ interconnected tables
|
|
389
|
+
- ❌ Version-dependent structure
|
|
390
|
+
- ❌ No validation via API
|
|
391
|
+
- ✅ Instead: Create manually, export via update set
|
|
392
|
+
|
|
393
|
+
**2. Use Puppeteer for ServiceNow Automation**
|
|
394
|
+
- ❌ 10-30 second operations
|
|
395
|
+
- ❌ Brittle selectors break on UI changes
|
|
396
|
+
- ❌ High maintenance burden
|
|
397
|
+
- ❌ Security concerns
|
|
398
|
+
- ✅ Instead: Use REST API + UI endpoints + background scripts
|
|
399
|
+
|
|
400
|
+
**3. Set Update Set via sys_user_preference**
|
|
401
|
+
- ❌ Only changes UI display, not actual capture
|
|
402
|
+
- ❌ Doesn't work for API-driven changes
|
|
403
|
+
- ✅ Instead: Use `SN-Set-Update-Set` (UI API endpoint)
|
|
404
|
+
|
|
405
|
+
**4. Execute Scripts via /sys.scripts.do**
|
|
406
|
+
- ❌ HTML output, hard to parse
|
|
407
|
+
- ❌ Session management complexity
|
|
408
|
+
- ✅ Instead: Use sys_trigger (automated, clean)
|
|
409
|
+
|
|
410
|
+
**5. Manual Fix Scripts for Everything**
|
|
411
|
+
- ❌ Requires manual copy-paste
|
|
412
|
+
- ❌ Slow workflow
|
|
413
|
+
- ✅ Instead: Use sys_trigger for automated execution
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## Success Patterns
|
|
418
|
+
|
|
419
|
+
### ✅ Do This
|
|
420
|
+
|
|
421
|
+
**1. Always Set Update Set First**
|
|
422
|
+
```javascript
|
|
423
|
+
// CORRECT order
|
|
424
|
+
await SN-Set-Update-Set({ update_set_sys_id: 'abc' });
|
|
425
|
+
await SN-Create-Record({ table: 'sys_properties', data: {...} });
|
|
426
|
+
|
|
427
|
+
// WRONG order - goes to Default set!
|
|
428
|
+
await SN-Create-Record({ table: 'sys_properties', data: {...} });
|
|
429
|
+
await SN-Set-Update-Set({ update_set_sys_id: 'abc' });
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**2. Use Batch Operations for Multiple Records**
|
|
433
|
+
```javascript
|
|
434
|
+
// GOOD: One batch operation
|
|
435
|
+
await SN-Batch-Update({
|
|
436
|
+
updates: [
|
|
437
|
+
{ table: 'incident', sys_id: 'id1', data: {state: 6} },
|
|
438
|
+
{ table: 'incident', sys_id: 'id2', data: {state: 6} },
|
|
439
|
+
// ... 41 more
|
|
440
|
+
]
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
// BAD: 43 individual operations
|
|
444
|
+
for (const record of records) {
|
|
445
|
+
await SN-Update-Record({ table: 'incident', sys_id: record.sys_id, data: {...} });
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
**3. Verify Update Set Capture**
|
|
450
|
+
```javascript
|
|
451
|
+
// Create configuration
|
|
452
|
+
await SN-Create-Record({ table: 'sys_properties', data: {...} });
|
|
453
|
+
|
|
454
|
+
// Verify captured
|
|
455
|
+
const captured = await SN-Query-Table({
|
|
456
|
+
table_name: 'sys_update_xml',
|
|
457
|
+
query: 'update_set=<your_set_id>',
|
|
458
|
+
fields: 'name,type,sys_created_on'
|
|
459
|
+
});
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
**4. Use FlowAPI for Flow Execution**
|
|
463
|
+
```javascript
|
|
464
|
+
// Create flow once in UI
|
|
465
|
+
// Then execute programmatically many times
|
|
466
|
+
await SN-Execute-Background-Script({
|
|
467
|
+
script: `
|
|
468
|
+
var inputs = { incident_sys_id: 'abc' };
|
|
469
|
+
var outputs = sn_fd.FlowAPI.executeFlow('flow_sys_id', inputs);
|
|
470
|
+
gs.print(JSON.stringify(outputs));
|
|
471
|
+
`
|
|
472
|
+
});
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
**5. Use Templates for Common Patterns**
|
|
476
|
+
```javascript
|
|
477
|
+
// Use workflow templates
|
|
478
|
+
await SN-Create-Workflow({
|
|
479
|
+
name: 'Auto-Approve Low Risk',
|
|
480
|
+
table: 'change_request',
|
|
481
|
+
activities: [...], // From template
|
|
482
|
+
transitions: [...] // From template
|
|
483
|
+
});
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
## Quick Reference Card
|
|
489
|
+
|
|
490
|
+
### Top 10 Most Used Operations
|
|
491
|
+
|
|
492
|
+
| # | Operation | Tool | Time | When to Use |
|
|
493
|
+
|---|-----------|------|------|-------------|
|
|
494
|
+
| 1 | Query records | `SN-Query-Table` | <1s | Always for reading data |
|
|
495
|
+
| 2 | Create record | `SN-Create-Record` | <1s | Always for creating data |
|
|
496
|
+
| 3 | Update record | `SN-Update-Record` | <1s | Always for updating data |
|
|
497
|
+
| 4 | Set update set | `SN-Set-Update-Set` | ~2s | Before config changes |
|
|
498
|
+
| 5 | Get update set | `SN-Get-Current-Update-Set` | <1s | Verify current set |
|
|
499
|
+
| 6 | Inspect set | `SN-Inspect-Update-Set` | <1s | Check set contents |
|
|
500
|
+
| 7 | Execute script | `SN-Execute-Background-Script` | ~1s | Complex operations |
|
|
501
|
+
| 8 | Batch update | `SN-Batch-Update` | 2-5s | Multiple records |
|
|
502
|
+
| 9 | Create workflow | `SN-Create-Workflow` | <1s | Automated workflows |
|
|
503
|
+
| 10 | Get table schema | `SN-Get-Table-Schema` | <1s | Discover fields |
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## Conclusion
|
|
508
|
+
|
|
509
|
+
### The Right Tool for the Job
|
|
510
|
+
|
|
511
|
+
```
|
|
512
|
+
┌─────────────────────────────────────────────────┐
|
|
513
|
+
│ 95% of operations: FULLY AUTOMATED ✅ │
|
|
514
|
+
│ • REST API │
|
|
515
|
+
│ • UI API endpoints │
|
|
516
|
+
│ • Background scripts (sys_trigger) │
|
|
517
|
+
│ • Performance: <2 seconds │
|
|
518
|
+
│ • Reliability: 99%+ │
|
|
519
|
+
├─────────────────────────────────────────────────┤
|
|
520
|
+
│ 5% of operations: MANUAL WITH WORKAROUNDS ⚠️ │
|
|
521
|
+
│ • Flow Designer creation (one-time) │
|
|
522
|
+
│ • UI-only configs (rare) │
|
|
523
|
+
│ • Acceptable trade-off │
|
|
524
|
+
│ • Clear documentation provided │
|
|
525
|
+
└─────────────────────────────────────────────────┘
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
**Key Takeaway:** Use the right tool for each operation type. Don't over-engineer solutions for edge cases that have acceptable workarounds.
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
532
|
+
## Related Documentation
|
|
533
|
+
|
|
534
|
+
- **Complete Architecture:** `docs/UI_OPERATIONS_ARCHITECTURE.md`
|
|
535
|
+
- **Executive Summary:** `docs/UI_OPERATIONS_SUMMARY.md`
|
|
536
|
+
- **Flow Designer Guide:** `docs/FLOW_DESIGNER_GUIDE.md`
|
|
537
|
+
- **API Reference:** `docs/API_REFERENCE.md`
|
|
538
|
+
- **Research:** `docs/research/FLOW_DESIGNER_LIMITATIONS.md`
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
**END OF DECISION MATRIX**
|