snow-flow 3.0.9 → 3.0.13
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-flow.bat +0 -0
- package/claude-flow.ps1 +0 -0
- package/dist/mcp/intelligent-reporting-mcp.d.ts +7 -0
- package/dist/mcp/intelligent-reporting-mcp.js +379 -0
- package/dist/mcp/servicenow-automation-mcp.js +0 -0
- package/dist/mcp/servicenow-deployment-mcp.js +0 -0
- package/dist/mcp/servicenow-integration-mcp.js +0 -0
- package/dist/mcp/servicenow-mcp-server.js +0 -0
- package/dist/mcp/servicenow-operations-mcp.js +0 -0
- package/dist/mcp/servicenow-platform-development-mcp.js +0 -0
- package/dist/mcp/servicenow-progressive-indexer.js +0 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.js +280 -29
- package/dist/mcp/servicenow-security-compliance-mcp.js +0 -0
- package/dist/mcp/servicenow-update-set-mcp.js +0 -0
- package/dist/mcp/start-all-mcp-servers.js +0 -0
- package/dist/mcp/start-servicenow-mcp.js +0 -0
- package/dist/services/widget-deployment-service.d.ts +2 -1
- package/dist/services/widget-deployment-service.js +17 -16
- package/dist/utils/anti-mock-data-validator.d.ts +66 -0
- package/dist/utils/anti-mock-data-validator.js +316 -0
- package/dist/utils/servicenow-eventual-consistency.d.ts +120 -0
- package/dist/utils/servicenow-eventual-consistency.js +220 -0
- package/memory/agents/README.md +1 -1
- package/memory/claude-flow-data.json +1 -1
- package/memory/sessions/README.md +1 -1
- package/package.json +4 -3
- package/.mcp.json +0 -22
- package/claude-flow.config.json +0 -20
- package/dist/agents/app-creator.agent.d.ts +0 -55
- package/dist/agents/app-creator.agent.js +0 -1292
- package/dist/agents/base/base-snow-agent.d.ts +0 -75
- package/dist/agents/base/base-snow-agent.js +0 -169
- package/dist/agents/base-snow-agent.d.ts +0 -63
- package/dist/agents/base-snow-agent.js +0 -296
- package/dist/agents/coordinator.d.ts +0 -200
- package/dist/agents/coordinator.js +0 -777
- package/dist/agents/flow-builder-agent.d.ts +0 -18
- package/dist/agents/flow-builder-agent.js +0 -197
- package/dist/agents/queen-403-handler.d.ts +0 -47
- package/dist/agents/queen-403-handler.js +0 -175
- package/dist/agents/queen-agent-example.d.ts +0 -23
- package/dist/agents/queen-agent-example.js +0 -240
- package/dist/agents/queen-agent.test.d.ts +0 -6
- package/dist/agents/script-generator.agent.d.ts +0 -32
- package/dist/agents/script-generator.agent.js +0 -772
- package/dist/agents/script-writer-agent.d.ts +0 -22
- package/dist/agents/script-writer-agent.js +0 -695
- package/dist/agents/security-agent.d.ts +0 -23
- package/dist/agents/security-agent.js +0 -619
- package/dist/agents/specialists/automation-specialist.agent.d.ts +0 -44
- package/dist/agents/specialists/automation-specialist.agent.js +0 -204
- package/dist/agents/specialists/data-specialist.agent.d.ts +0 -165
- package/dist/agents/specialists/data-specialist.agent.js +0 -484
- package/dist/agents/specialists/integration-specialist.agent.d.ts +0 -227
- package/dist/agents/specialists/integration-specialist.agent.js +0 -725
- package/dist/agents/specialists/reporting-specialist.agent.d.ts +0 -54
- package/dist/agents/specialists/reporting-specialist.agent.js +0 -193
- package/dist/agents/specialists/security-specialist.agent.d.ts +0 -85
- package/dist/agents/specialists/security-specialist.agent.js +0 -309
- package/dist/agents/teams/adaptive/adaptive-coordinator.agent.d.ts +0 -111
- package/dist/agents/teams/adaptive/adaptive-coordinator.agent.js +0 -383
- package/dist/agents/teams/base-team.d.ts +0 -72
- package/dist/agents/teams/base-team.js +0 -253
- package/dist/agents/teams/team-types.d.ts +0 -265
- package/dist/agents/teams/team-types.js +0 -3
- package/dist/agents/teams/widget/widget-architect.agent.d.ts +0 -61
- package/dist/agents/teams/widget/widget-architect.agent.js +0 -436
- package/dist/agents/teams/widget/widget-backend.agent.d.ts +0 -74
- package/dist/agents/teams/widget/widget-backend.agent.js +0 -1531
- package/dist/agents/teams/widget/widget-frontend.agent.d.ts +0 -67
- package/dist/agents/teams/widget/widget-frontend.agent.js +0 -1014
- package/dist/agents/teams/widget/widget-platform.agent.d.ts +0 -90
- package/dist/agents/teams/widget/widget-platform.agent.js +0 -1190
- package/dist/agents/teams/widget/widget-uiux.agent.d.ts +0 -107
- package/dist/agents/teams/widget/widget-uiux.agent.js +0 -1033
- package/dist/agents/test-agent.d.ts +0 -26
- package/dist/agents/test-agent.js +0 -734
- package/dist/agents/test-agents.d.ts +0 -7
- package/dist/agents/test-agents.js +0 -64
- package/dist/agents/ui-builder.agent.d.ts +0 -50
- package/dist/agents/ui-builder.agent.js +0 -1539
- package/dist/agents/widget-builder.agent.d.ts +0 -32
- package/dist/agents/widget-builder.agent.js +0 -439
- package/dist/agents/widget-creator-agent.d.ts +0 -18
- package/dist/agents/widget-creator-agent.js +0 -498
- package/dist/agents/workflow-designer.agent.d.ts +0 -31
- package/dist/agents/workflow-designer.agent.js +0 -583
- package/dist/api/error-handling.d.ts +0 -325
- package/dist/api/error-handling.js +0 -1488
- package/dist/api/flow-designer-api.d.ts +0 -167
- package/dist/api/flow-designer-api.js +0 -554
- package/dist/api/natural-language-mapper.d.ts +0 -124
- package/dist/api/natural-language-mapper.js +0 -501
- package/dist/api/performance-optimizer.d.ts +0 -240
- package/dist/api/performance-optimizer.js +0 -706
- package/dist/api/transaction-manager.d.ts +0 -189
- package/dist/api/transaction-manager.js +0 -576
- package/dist/assembly/team-assembler.d.ts +0 -140
- package/dist/assembly/team-assembler.js +0 -502
- package/dist/benchmark-performance.d.ts +0 -41
- package/dist/benchmark-performance.js +0 -230
- package/dist/cli/snow-flow-cli-integration.d.ts +0 -30
- package/dist/cli/snow-flow-cli-integration.js +0 -396
- package/dist/coordination/coordination-engine.d.ts +0 -41
- package/dist/coordination/coordination-engine.js +0 -324
- package/dist/coordination/coordination.test.d.ts +0 -6
- package/dist/coordination/example.d.ts +0 -31
- package/dist/coordination/example.js +0 -394
- package/dist/coordination/execution-patterns.d.ts +0 -43
- package/dist/coordination/execution-patterns.js +0 -507
- package/dist/coordination/factory.d.ts +0 -94
- package/dist/coordination/factory.js +0 -433
- package/dist/coordination/index.d.ts +0 -71
- package/dist/coordination/index.js +0 -135
- package/dist/coordination/progress-monitor.d.ts +0 -71
- package/dist/coordination/progress-monitor.js +0 -505
- package/dist/coordination/quality-gates.d.ts +0 -124
- package/dist/coordination/quality-gates.js +0 -577
- package/dist/coordination/shared-memory.d.ts +0 -39
- package/dist/coordination/shared-memory.js +0 -289
- package/dist/coordination/task-dependencies.d.ts +0 -50
- package/dist/coordination/task-dependencies.js +0 -407
- package/dist/coordination/team-coordinator.d.ts +0 -59
- package/dist/coordination/team-coordinator.js +0 -550
- package/dist/coordination/types.d.ts +0 -152
- package/dist/coordination/types.js +0 -3
- package/dist/mcp/mcp-wrapper.d.ts +0 -8
- package/dist/mcp/mcp-wrapper.js +0 -77
- package/dist/mcp/servicenow-flow-composer-enhanced.js +0 -396
- package/dist/mcp/servicenow-flow-composer-mcp.d.ts +0 -7
- package/dist/mcp/servicenow-flow-composer-mcp.js +0 -3103
- package/dist/mcp/servicenow-graph-memory-mcp.d.ts +0 -7
- package/dist/mcp/servicenow-intelligent-mcp.d.ts +0 -143
- package/dist/mcp/servicenow-intelligent-mcp.js +0 -4156
- package/dist/mcp/servicenow-xml-flow-mcp.d.ts +0 -53
- package/dist/mcp/servicenow-xml-flow-mcp.js +0 -1704
- package/dist/mcp/singleton-check.js +0 -31
- package/dist/mcp/test-simple-mcp.d.ts +0 -6
- package/dist/mcp/test-simple-mcp.js +0 -63
- package/dist/memory/hierarchical-memory-system.d.ts +0 -90
- package/dist/memory/hierarchical-memory-system.js +0 -400
- package/dist/memory/index.d.ts +0 -9
- package/dist/memory/index.js +0 -20
- package/dist/memory/mcp-integration-example.d.ts +0 -6
- package/dist/memory/mcp-integration-example.js +0 -281
- package/dist/memory/memory-client.d.ts +0 -199
- package/dist/memory/memory-client.js +0 -364
- package/dist/memory/memory-manager.d.ts +0 -29
- package/dist/memory/memory-manager.js +0 -280
- package/dist/memory/memory-operations.d.ts +0 -179
- package/dist/memory/memory-operations.js +0 -691
- package/dist/memory/memory-system.d.ts +0 -153
- package/dist/memory/memory-system.js +0 -651
- package/dist/memory/memory-test.d.ts +0 -6
- package/dist/memory/memory-test.js +0 -161
- package/dist/memory/snow-flow-memory-patterns.d.ts +0 -213
- package/dist/memory/snow-flow-memory-patterns.js +0 -200
- package/dist/memory/snow-memory.d.ts +0 -54
- package/dist/memory/snow-memory.js +0 -301
- package/dist/memory/swarm-memory.d.ts +0 -135
- package/dist/memory/swarm-memory.js +0 -378
- package/dist/optimization/flow-performance-optimizer.js +0 -723
- package/dist/orchestration/discovery/service-discovery.d.ts +0 -81
- package/dist/orchestration/discovery/service-discovery.js +0 -808
- package/dist/orchestration/distributed-orchestrator.d.ts +0 -131
- package/dist/orchestration/distributed-orchestrator.js +0 -712
- package/dist/orchestration/distribution/task-distribution-engine.d.ts +0 -53
- package/dist/orchestration/distribution/task-distribution-engine.js +0 -586
- package/dist/orchestration/flow-update-orchestrator.js +0 -648
- package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +0 -606
- package/dist/orchestration/interfaces/distributed-orchestration.interface.js +0 -65
- package/dist/orchestration/protocols/mcpx-protocol.d.ts +0 -71
- package/dist/orchestration/protocols/mcpx-protocol.js +0 -668
- package/dist/orchestration/state/distributed-state-manager.d.ts +0 -89
- package/dist/orchestration/state/distributed-state-manager.js +0 -716
- package/dist/orchestrator/flow-composer.d.ts +0 -105
- package/dist/orchestrator/flow-composer.js +0 -404
- package/dist/orchestrator/flow-pattern-templates.d.ts +0 -260
- package/dist/orchestrator/flow-pattern-templates.js +0 -908
- package/dist/orchestrator/flow-subflow-decision-engine.d.ts +0 -202
- package/dist/orchestrator/flow-subflow-decision-engine.js +0 -769
- package/dist/orchestrator/flow-validation-engine.d.ts +0 -169
- package/dist/orchestrator/flow-validation-engine.js +0 -913
- package/dist/orchestrator/snow-orchestrator.d.ts +0 -49
- package/dist/orchestrator/snow-orchestrator.js +0 -235
- package/dist/orchestrator/subflow-creation-handler.d.ts +0 -230
- package/dist/orchestrator/subflow-creation-handler.js +0 -791
- package/dist/patterns/adaptive-patterns.d.ts +0 -140
- package/dist/patterns/adaptive-patterns.js +0 -549
- package/dist/queen/advanced-integration-test.d.ts +0 -48
- package/dist/queen/advanced-integration-test.js +0 -473
- package/dist/queen/integration-example.d.ts +0 -82
- package/dist/queen/integration-example.js +0 -219
- package/dist/queen/integration-test.d.ts +0 -72
- package/dist/queen/integration-test.js +0 -563
- package/dist/queen/mock-mcp-client.d.ts +0 -71
- package/dist/queen/mock-mcp-client.js +0 -317
- package/dist/queen/run-integration-tests.d.ts +0 -9
- package/dist/queen/run-integration-tests.js +0 -27
- package/dist/sparc/coordinators/adaptive-coordinator.d.ts +0 -54
- package/dist/sparc/coordinators/adaptive-coordinator.js +0 -367
- package/dist/sparc/coordinators/team-coordinator.d.ts +0 -66
- package/dist/sparc/coordinators/team-coordinator.js +0 -402
- package/dist/sparc/modes/team-modes.d.ts +0 -33
- package/dist/sparc/modes/team-modes.js +0 -399
- package/dist/sparc/teams/application-team.d.ts +0 -73
- package/dist/sparc/teams/application-team.js +0 -463
- package/dist/sparc/teams/flow-team.d.ts +0 -67
- package/dist/sparc/teams/flow-team.js +0 -373
- package/dist/sparc/teams/widget-team.d.ts +0 -61
- package/dist/sparc/teams/widget-team.js +0 -280
- package/dist/specialists/app-specialists.d.ts +0 -93
- package/dist/specialists/app-specialists.js +0 -1639
- package/dist/specialists/base-specialist.d.ts +0 -19
- package/dist/specialists/base-specialist.js +0 -54
- package/dist/specialists/flow-specialists.d.ts +0 -113
- package/dist/specialists/flow-specialists.js +0 -1787
- package/dist/specialists/individual-specialists.d.ts +0 -67
- package/dist/specialists/individual-specialists.js +0 -632
- package/dist/specialists/widget-specialists.d.ts +0 -70
- package/dist/specialists/widget-specialists.js +0 -1264
- package/dist/src/utils/agent-detector.js +0 -655
- package/dist/teams/adaptive-team.d.ts +0 -81
- package/dist/teams/adaptive-team.js +0 -1153
- package/dist/teams/application-team.d.ts +0 -30
- package/dist/teams/application-team.js +0 -547
- package/dist/teams/base-team.d.ts +0 -55
- package/dist/teams/base-team.js +0 -243
- package/dist/teams/flow-team.d.ts +0 -28
- package/dist/teams/flow-team.js +0 -525
- package/dist/teams/widget-team.d.ts +0 -26
- package/dist/teams/widget-team.js +0 -459
- package/dist/templates/flow-template-system.js +0 -625
- package/dist/test-fetch-incidents.d.ts +0 -2
- package/dist/test-fetch-incidents.js +0 -84
- package/dist/test-incident-access.d.ts +0 -2
- package/dist/test-incident-access.js +0 -72
- package/dist/test-iphone-flow.js +0 -189
- package/dist/test-limit-problem.d.ts +0 -2
- package/dist/test-limit-problem.js +0 -60
- package/dist/test-ml-batch-fix.d.ts +0 -2
- package/dist/test-ml-batch-fix.js +0 -104
- package/dist/test-ml-batch.d.ts +0 -2
- package/dist/test-ml-batch.js +0 -87
- package/dist/test-ml-query.d.ts +0 -2
- package/dist/test-ml-query.js +0 -100
- package/dist/test-ml-training-fix.d.ts +0 -12
- package/dist/test-ml-training-fix.js +0 -113
- package/dist/test-ml-training.d.ts +0 -2
- package/dist/test-ml-training.js +0 -32
- package/dist/test-operations-query.d.ts +0 -2
- package/dist/test-operations-query.js +0 -84
- package/dist/test-performance-query.d.ts +0 -2
- package/dist/test-performance-query.js +0 -52
- package/dist/test-singleton-protection.d.ts +0 -8
- package/dist/test-singleton-protection.js +0 -110
- package/dist/test-smart-limits.d.ts +0 -13
- package/dist/test-smart-limits.js +0 -100
- package/dist/test-snow-query-incidents.d.ts +0 -2
- package/dist/test-snow-query-incidents.js +0 -66
- package/dist/test-universal-query.d.ts +0 -2
- package/dist/test-universal-query.js +0 -106
- package/dist/testing/flow-testing-automation.js +0 -641
- package/dist/utils/complete-flow-xml-generator.js +0 -1285
- package/dist/utils/file-storage-fallback.d.ts +0 -62
- package/dist/utils/file-storage-fallback.js +0 -289
- package/dist/utils/flow-api-discovery.d.ts +0 -151
- package/dist/utils/flow-api-discovery.js +0 -439
- package/dist/utils/flow-examples.js +0 -720
- package/dist/utils/flow-structure-builder.js +0 -677
- package/dist/utils/flow-xml-generator.d.ts +0 -41
- package/dist/utils/flow-xml-generator.js +0 -258
- package/dist/utils/improved-flow-xml-generator.js +0 -820
- package/dist/utils/mcp-process-manager.backup.d.ts +0 -58
- package/dist/utils/mcp-process-manager.backup.js +0 -220
- package/dist/utils/mcp-singleton-enforcer.d.ts +0 -36
- package/dist/utils/mcp-singleton-enforcer.js +0 -201
- package/dist/utils/mcp-timeout-fix.d.ts +0 -53
- package/dist/utils/mcp-timeout-fix.js +0 -221
- package/dist/utils/migrate-claude-flow.d.ts +0 -22
- package/dist/utils/migrate-claude-flow.js +0 -120
- package/dist/utils/scope-utils.d.ts +0 -72
- package/dist/utils/scope-utils.js +0 -386
- package/dist/utils/snow-oauth-old.d.ts +0 -65
- package/dist/utils/snow-oauth-old.js +0 -345
- package/dist/utils/xml-first-flow-generator.js +0 -513
- package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +0 -30
- package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +0 -36
- package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +0 -30
- package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +0 -30
- package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +0 -55
- package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +0 -55
- package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +0 -9
- package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +0 -9
- package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +0 -8
- package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +0 -9
- package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +0 -9
- package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +0 -9
- package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +0 -58
- package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +0 -9
- package/reports/swarm-auto-centralized-1752649029776.json +0 -13
- package/src/memory/README.md +0 -240
|
@@ -1,1704 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
/**
|
|
4
|
-
* ServiceNow XML Flow MCP Server
|
|
5
|
-
* Provides XML-first flow generation capabilities
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.ServiceNowXMLFlowMCP = void 0;
|
|
42
|
-
const base_mcp_server_1 = require("./base-mcp-server");
|
|
43
|
-
// Flow generators removed in v1.4.0
|
|
44
|
-
// import any, { ImprovedFlowDefinition, any, // generateImprovedFlowXML deprecated } from '../utils/improved-flow-xml-generator';
|
|
45
|
-
// import { any, any, // generateProductionFlowXML deprecated } from '../utils/xml-first-flow-generator';
|
|
46
|
-
const natural_language_mapper_1 = require("../api/natural-language-mapper");
|
|
47
|
-
const servicenow_id_generator_js_1 = require("../utils/servicenow-id-generator.js");
|
|
48
|
-
const fs = __importStar(require("fs"));
|
|
49
|
-
const path = __importStar(require("path"));
|
|
50
|
-
class ServiceNowXMLFlowMCP extends base_mcp_server_1.BaseMCPServer {
|
|
51
|
-
constructor() {
|
|
52
|
-
super({
|
|
53
|
-
name: 'servicenow-xml-flow',
|
|
54
|
-
version: '1.0.0',
|
|
55
|
-
description: 'XML-first flow generation for ServiceNow - bypasses API issues'
|
|
56
|
-
});
|
|
57
|
-
this.nlMapper = new natural_language_mapper_1.NaturalLanguageMapper();
|
|
58
|
-
}
|
|
59
|
-
setupTools() {
|
|
60
|
-
// Generate complete flow XML
|
|
61
|
-
this.registerTool({
|
|
62
|
-
name: 'snow_xml_flow_generate',
|
|
63
|
-
description: 'Generate complete Update Set XML for a flow that can be imported directly into ServiceNow',
|
|
64
|
-
inputSchema: {
|
|
65
|
-
type: 'object',
|
|
66
|
-
properties: {
|
|
67
|
-
name: {
|
|
68
|
-
type: 'string',
|
|
69
|
-
description: 'Flow name'
|
|
70
|
-
},
|
|
71
|
-
description: {
|
|
72
|
-
type: 'string',
|
|
73
|
-
description: 'Flow description'
|
|
74
|
-
},
|
|
75
|
-
table: {
|
|
76
|
-
type: 'string',
|
|
77
|
-
description: 'Table to trigger on (e.g., incident, sc_request)'
|
|
78
|
-
},
|
|
79
|
-
trigger_type: {
|
|
80
|
-
type: 'string',
|
|
81
|
-
enum: ['record_created', 'record_updated', 'manual', 'scheduled'],
|
|
82
|
-
description: 'Trigger type'
|
|
83
|
-
},
|
|
84
|
-
trigger_condition: {
|
|
85
|
-
type: 'string',
|
|
86
|
-
description: 'Trigger condition (encoded query)'
|
|
87
|
-
},
|
|
88
|
-
activities: {
|
|
89
|
-
type: 'array',
|
|
90
|
-
description: 'Flow activities',
|
|
91
|
-
items: {
|
|
92
|
-
type: 'object',
|
|
93
|
-
properties: {
|
|
94
|
-
name: { type: 'string' },
|
|
95
|
-
type: {
|
|
96
|
-
type: 'string',
|
|
97
|
-
enum: ['notification', 'approval', 'script', 'create_record', 'update_record', 'rest_step']
|
|
98
|
-
},
|
|
99
|
-
order: { type: 'number' },
|
|
100
|
-
inputs: { type: 'object' },
|
|
101
|
-
outputs: { type: 'object' },
|
|
102
|
-
condition: { type: 'string' }
|
|
103
|
-
},
|
|
104
|
-
required: ['name', 'type', 'inputs']
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
update_set_name: {
|
|
108
|
-
type: 'string',
|
|
109
|
-
description: 'Name for the Update Set (optional)'
|
|
110
|
-
},
|
|
111
|
-
save_to_file: {
|
|
112
|
-
type: 'boolean',
|
|
113
|
-
default: true,
|
|
114
|
-
description: 'Save XML to file'
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
required: ['name', 'description', 'trigger_type', 'activities']
|
|
118
|
-
}
|
|
119
|
-
}, this.generateFlowXML.bind(this));
|
|
120
|
-
// Generate flow XML from natural language
|
|
121
|
-
this.registerTool({
|
|
122
|
-
name: 'snow_xml_flow_from_instruction',
|
|
123
|
-
description: '⚠️ DEPRECATED - Use snow_create_flow instead. This tool is kept for backwards compatibility only.',
|
|
124
|
-
inputSchema: {
|
|
125
|
-
type: 'object',
|
|
126
|
-
properties: {
|
|
127
|
-
instruction: {
|
|
128
|
-
type: 'string',
|
|
129
|
-
description: 'Natural language description of the flow (e.g., "create approval flow for iPhone requests")'
|
|
130
|
-
},
|
|
131
|
-
save_to_file: {
|
|
132
|
-
type: 'boolean',
|
|
133
|
-
default: true,
|
|
134
|
-
description: 'Save XML to file'
|
|
135
|
-
},
|
|
136
|
-
auto_deploy: {
|
|
137
|
-
type: 'boolean',
|
|
138
|
-
default: true,
|
|
139
|
-
description: 'Automatically deploy XML to ServiceNow after generation (RECOMMENDED)'
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
required: ['instruction']
|
|
143
|
-
}
|
|
144
|
-
}, this.generateFlowFromInstruction.bind(this));
|
|
145
|
-
// Generate example flows
|
|
146
|
-
this.registerTool({
|
|
147
|
-
name: 'snow_xml_flow_examples',
|
|
148
|
-
description: 'Generate example flow XML files with common patterns',
|
|
149
|
-
inputSchema: {
|
|
150
|
-
type: 'object',
|
|
151
|
-
properties: {
|
|
152
|
-
example_type: {
|
|
153
|
-
type: 'string',
|
|
154
|
-
enum: ['approval', 'incident_notification', 'equipment_provisioning', 'data_processing', 'user_onboarding'],
|
|
155
|
-
description: 'Type of example flow to generate'
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
required: ['example_type']
|
|
159
|
-
}
|
|
160
|
-
}, this.generateExampleFlow.bind(this));
|
|
161
|
-
// List generated XML files
|
|
162
|
-
this.registerTool({
|
|
163
|
-
name: 'snow_xml_flow_list',
|
|
164
|
-
description: 'List all generated flow XML files',
|
|
165
|
-
inputSchema: {
|
|
166
|
-
type: 'object',
|
|
167
|
-
properties: {}
|
|
168
|
-
}
|
|
169
|
-
}, this.listGeneratedFiles.bind(this));
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Generate flow XML from definition using IMPROVED generator
|
|
173
|
-
*/
|
|
174
|
-
async generateFlowXML(args) {
|
|
175
|
-
try {
|
|
176
|
-
// Convert to improved flow definition
|
|
177
|
-
const flowDef = {
|
|
178
|
-
name: args.name,
|
|
179
|
-
description: args.description,
|
|
180
|
-
table: args.table,
|
|
181
|
-
trigger_type: args.trigger_type,
|
|
182
|
-
trigger_condition: args.trigger_condition,
|
|
183
|
-
run_as: args.run_as || 'user',
|
|
184
|
-
accessible_from: args.accessible_from || 'package_private',
|
|
185
|
-
category: args.category || 'custom',
|
|
186
|
-
tags: args.tags || [],
|
|
187
|
-
activities: args.activities.map((act, index) => ({
|
|
188
|
-
...act,
|
|
189
|
-
order: act.order || (index + 1) * 100,
|
|
190
|
-
description: act.description || act.name
|
|
191
|
-
}))
|
|
192
|
-
};
|
|
193
|
-
// Use IMPROVED generator (fixes "too small to work" issue!)
|
|
194
|
-
// Flow generation removed in v1.4.0
|
|
195
|
-
const result = { xml: '<!-- Flow generation deprecated -->', filePath: null, instructions: 'Deprecated' };
|
|
196
|
-
return {
|
|
197
|
-
success: true,
|
|
198
|
-
xml: args.save_to_file === false ? result.xml : undefined,
|
|
199
|
-
file_path: result.filePath,
|
|
200
|
-
message: `✅ Generated IMPROVED Update Set XML for flow: ${args.name}`,
|
|
201
|
-
improvements: [
|
|
202
|
-
'✅ Uses sys_hub_action_instance_v2 and sys_hub_trigger_instance_v2 (correct table versions)',
|
|
203
|
-
'✅ Base64+gzip encoded action values (production format)',
|
|
204
|
-
'✅ Complete label_cache structure (critical for Flow Designer)',
|
|
205
|
-
'✅ ALL minimum required fields for sys_hub_flow',
|
|
206
|
-
'✅ Comprehensive flow snapshot with proper metadata'
|
|
207
|
-
],
|
|
208
|
-
import_instructions: result.instructions,
|
|
209
|
-
flow_structure: {
|
|
210
|
-
activities_count: flowDef.activities.length,
|
|
211
|
-
trigger_type: flowDef.trigger_type,
|
|
212
|
-
table: flowDef.table || 'none',
|
|
213
|
-
category: flowDef.category,
|
|
214
|
-
tags: flowDef.tags
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
return {
|
|
220
|
-
success: false,
|
|
221
|
-
error: error instanceof Error ? error.message : String(error)
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Generate flow from natural language instruction using IMPROVED generator
|
|
227
|
-
*/
|
|
228
|
-
async generateFlowFromInstruction(args) {
|
|
229
|
-
try {
|
|
230
|
-
const { instruction, auto_deploy = true } = args;
|
|
231
|
-
// Parse natural language to flow components
|
|
232
|
-
// Flow requirements parsing removed in v1.4.0
|
|
233
|
-
const flowRequirements = {};
|
|
234
|
-
// Convert to IMPROVED flow definition
|
|
235
|
-
const flowDef = {
|
|
236
|
-
name: flowRequirements.name || `Flow ${Date.now()}`,
|
|
237
|
-
description: flowRequirements.description || instruction,
|
|
238
|
-
table: flowRequirements.tables?.[0] || 'incident',
|
|
239
|
-
trigger_type: this.mapTriggerType(flowRequirements.trigger_type || 'manual'),
|
|
240
|
-
trigger_condition: flowRequirements.trigger_condition || '',
|
|
241
|
-
run_as: 'user',
|
|
242
|
-
accessible_from: 'package_private',
|
|
243
|
-
category: 'custom',
|
|
244
|
-
tags: ['auto-generated'],
|
|
245
|
-
activities: this.convertToImprovedActivities(flowRequirements)
|
|
246
|
-
};
|
|
247
|
-
// Use PRODUCTION-READY generator with proper Update Set structure
|
|
248
|
-
// Production flow generation removed in v1.4.0
|
|
249
|
-
const result = { xml: '<!-- Production flow generation deprecated -->', filePath: null };
|
|
250
|
-
let deploymentResult = null;
|
|
251
|
-
// 🚀 AUTO-DEPLOYMENT: Deploy immediately if requested
|
|
252
|
-
if (auto_deploy) {
|
|
253
|
-
try {
|
|
254
|
-
this.logger.info('🚀 AUTO-DEPLOYING XML to ServiceNow...');
|
|
255
|
-
// Check authentication
|
|
256
|
-
const isAuth = await this.oauth.isAuthenticated();
|
|
257
|
-
if (!isAuth) {
|
|
258
|
-
throw new Error('Not authenticated with ServiceNow. Please run: snow-flow auth login');
|
|
259
|
-
}
|
|
260
|
-
// Initialize ServiceNow client
|
|
261
|
-
// ServiceNow client removed in v1.4.0
|
|
262
|
-
const client = null;
|
|
263
|
-
// Read the XML file
|
|
264
|
-
const fs = require('fs').promises;
|
|
265
|
-
const xmlContent = await fs.readFile(result.filePath, 'utf-8');
|
|
266
|
-
// Import XML as remote update set
|
|
267
|
-
const importResponse = await client.makeRequest({
|
|
268
|
-
method: 'POST',
|
|
269
|
-
url: '/api/now/table/sys_remote_update_set',
|
|
270
|
-
headers: {
|
|
271
|
-
'Content-Type': 'application/xml',
|
|
272
|
-
'Accept': 'application/json'
|
|
273
|
-
},
|
|
274
|
-
data: xmlContent
|
|
275
|
-
});
|
|
276
|
-
if (!importResponse.result || !importResponse.result.sys_id) {
|
|
277
|
-
throw new Error('Failed to import XML update set');
|
|
278
|
-
}
|
|
279
|
-
const remoteUpdateSetId = importResponse.result.sys_id;
|
|
280
|
-
this.logger.info(`✅ XML imported successfully (sys_id: ${remoteUpdateSetId})`);
|
|
281
|
-
// Load the update set
|
|
282
|
-
await client.makeRequest({
|
|
283
|
-
method: 'PUT',
|
|
284
|
-
url: `/api/now/table/sys_remote_update_set/${remoteUpdateSetId}`,
|
|
285
|
-
data: {
|
|
286
|
-
state: 'loaded'
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
// Find the loaded update set
|
|
290
|
-
const loadedResponse = await client.makeRequest({
|
|
291
|
-
method: 'GET',
|
|
292
|
-
url: '/api/now/table/sys_update_set',
|
|
293
|
-
params: {
|
|
294
|
-
sysparm_query: `remote_sys_id=${remoteUpdateSetId}`,
|
|
295
|
-
sysparm_limit: 1
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
if (!loadedResponse.result || loadedResponse.result.length === 0) {
|
|
299
|
-
throw new Error('Failed to find loaded update set');
|
|
300
|
-
}
|
|
301
|
-
const updateSetId = loadedResponse.result[0].sys_id;
|
|
302
|
-
const updateSetName = loadedResponse.result[0].name;
|
|
303
|
-
// Preview the update set
|
|
304
|
-
await client.makeRequest({
|
|
305
|
-
method: 'POST',
|
|
306
|
-
url: `/api/now/table/sys_update_set/${updateSetId}/preview`
|
|
307
|
-
});
|
|
308
|
-
// Check for preview problems
|
|
309
|
-
const previewProblems = await client.makeRequest({
|
|
310
|
-
method: 'GET',
|
|
311
|
-
url: '/api/now/table/sys_update_preview_problem',
|
|
312
|
-
params: {
|
|
313
|
-
sysparm_query: `update_set=${updateSetId}`,
|
|
314
|
-
sysparm_limit: 100
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
if (previewProblems.result && previewProblems.result.length > 0) {
|
|
318
|
-
const problemsList = previewProblems.result.map((p) => `- ${p.type}: ${p.description}`).join('\n');
|
|
319
|
-
throw new Error(`Preview found problems:\n${problemsList}\n\nPlease review and resolve in ServiceNow UI`);
|
|
320
|
-
}
|
|
321
|
-
// Commit the update set
|
|
322
|
-
await client.makeRequest({
|
|
323
|
-
method: 'POST',
|
|
324
|
-
url: `/api/now/table/sys_update_set/${updateSetId}/commit`
|
|
325
|
-
});
|
|
326
|
-
deploymentResult = {
|
|
327
|
-
success: true,
|
|
328
|
-
message: '✅ XML automatically deployed to ServiceNow!',
|
|
329
|
-
update_set_id: updateSetId,
|
|
330
|
-
update_set_name: updateSetName,
|
|
331
|
-
steps_completed: [
|
|
332
|
-
'✅ XML imported as remote update set',
|
|
333
|
-
'✅ Update set loaded successfully',
|
|
334
|
-
'✅ Preview completed with no problems',
|
|
335
|
-
'✅ Update set committed successfully'
|
|
336
|
-
]
|
|
337
|
-
};
|
|
338
|
-
this.logger.info('✅ Auto-deployment successful', deploymentResult);
|
|
339
|
-
}
|
|
340
|
-
catch (deployError) {
|
|
341
|
-
this.logger.warn('⚠️ Auto-deployment failed, providing manual instructions', deployError);
|
|
342
|
-
deploymentResult = {
|
|
343
|
-
success: false,
|
|
344
|
-
error: deployError instanceof Error ? deployError.message : String(deployError),
|
|
345
|
-
manual_command: `snow-flow deploy-xml ${result.filePath}`,
|
|
346
|
-
troubleshooting: [
|
|
347
|
-
'1. Check ServiceNow authentication: snow-flow auth status',
|
|
348
|
-
'2. Verify admin permissions in ServiceNow',
|
|
349
|
-
'3. Review XML file for format issues',
|
|
350
|
-
'4. Try manual deployment command above'
|
|
351
|
-
]
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return {
|
|
356
|
-
success: true,
|
|
357
|
-
xml: args.save_to_file === false ? result.xml : undefined,
|
|
358
|
-
file_path: result.filePath,
|
|
359
|
-
flow_definition: flowDef,
|
|
360
|
-
deployment: deploymentResult,
|
|
361
|
-
message: `✅ Generated IMPROVED flow XML from instruction: ${instruction}${deploymentResult?.success ? ' + DEPLOYED!' : ''}`,
|
|
362
|
-
improvements: [
|
|
363
|
-
'✅ Production-ready Flow Designer format',
|
|
364
|
-
'✅ Complete XML structure with all required fields',
|
|
365
|
-
'✅ Base64+gzip encoded action values',
|
|
366
|
-
'✅ Proper v2 table usage',
|
|
367
|
-
...(deploymentResult?.success ? ['✅ Automatically deployed to ServiceNow!'] : [])
|
|
368
|
-
],
|
|
369
|
-
import_instructions: deploymentResult?.success ? 'Flow is already deployed and ready to use!' : 'Flow generation deprecated in v1.4.0',
|
|
370
|
-
auto_deploy_command: deploymentResult?.manual_command || `snow-flow deploy-xml ${result.filePath}`
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
catch (error) {
|
|
374
|
-
return {
|
|
375
|
-
success: false,
|
|
376
|
-
error: error instanceof Error ? error.message : String(error)
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Generate example flows using IMPROVED generator
|
|
382
|
-
*/
|
|
383
|
-
async generateExampleFlow(args) {
|
|
384
|
-
try {
|
|
385
|
-
const { example_type } = args;
|
|
386
|
-
let flowDef;
|
|
387
|
-
switch (example_type) {
|
|
388
|
-
case 'approval':
|
|
389
|
-
// Flow examples removed in v1.4.0
|
|
390
|
-
flowDef = { name: 'Deprecated', activities: [] };
|
|
391
|
-
break;
|
|
392
|
-
case 'incident_notification':
|
|
393
|
-
flowDef = this.getImprovedIncidentNotificationExample();
|
|
394
|
-
break;
|
|
395
|
-
case 'equipment_provisioning':
|
|
396
|
-
flowDef = this.getImprovedEquipmentProvisioningExample();
|
|
397
|
-
break;
|
|
398
|
-
case 'data_processing':
|
|
399
|
-
flowDef = this.getImprovedDataProcessingExample();
|
|
400
|
-
break;
|
|
401
|
-
case 'user_onboarding':
|
|
402
|
-
flowDef = this.getImprovedUserOnboardingExample();
|
|
403
|
-
break;
|
|
404
|
-
default:
|
|
405
|
-
throw new Error(`Unknown example type: ${example_type}`);
|
|
406
|
-
}
|
|
407
|
-
// Use IMPROVED generator
|
|
408
|
-
// Flow generation removed in v1.4.0
|
|
409
|
-
const result = { xml: '<!-- Flow generation deprecated -->', filePath: null, instructions: 'Deprecated' };
|
|
410
|
-
return {
|
|
411
|
-
success: true,
|
|
412
|
-
xml: result.xml,
|
|
413
|
-
file_path: result.filePath,
|
|
414
|
-
flow_definition: flowDef,
|
|
415
|
-
message: `✅ Generated IMPROVED example ${example_type} flow - Production Ready!`,
|
|
416
|
-
improvements: [
|
|
417
|
-
'✅ Complete Flow Designer structure (not "too small")',
|
|
418
|
-
'✅ Base64+gzip encoded values',
|
|
419
|
-
'✅ Proper v2 table usage',
|
|
420
|
-
'✅ Full label_cache structure',
|
|
421
|
-
'✅ Production-ready metadata'
|
|
422
|
-
],
|
|
423
|
-
import_instructions: result.instructions,
|
|
424
|
-
warning: 'This is IMPROVED PRODUCTION-READY flow - much larger and more complete than previous version!'
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
catch (error) {
|
|
428
|
-
return {
|
|
429
|
-
success: false,
|
|
430
|
-
error: error instanceof Error ? error.message : String(error)
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* List generated XML files
|
|
436
|
-
*/
|
|
437
|
-
async listGeneratedFiles(args) {
|
|
438
|
-
try {
|
|
439
|
-
const outputDir = path.join(process.cwd(), 'flow-update-sets');
|
|
440
|
-
if (!fs.existsSync(outputDir)) {
|
|
441
|
-
return {
|
|
442
|
-
success: true,
|
|
443
|
-
files: [],
|
|
444
|
-
message: 'No flow XML files generated yet'
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
const files = fs.readdirSync(outputDir)
|
|
448
|
-
.filter(file => file.endsWith('.xml'))
|
|
449
|
-
.map(file => {
|
|
450
|
-
const filePath = path.join(outputDir, file);
|
|
451
|
-
const stats = fs.statSync(filePath);
|
|
452
|
-
return {
|
|
453
|
-
name: file,
|
|
454
|
-
path: filePath,
|
|
455
|
-
size: stats.size,
|
|
456
|
-
created: stats.birthtime,
|
|
457
|
-
modified: stats.mtime
|
|
458
|
-
};
|
|
459
|
-
})
|
|
460
|
-
.sort((a, b) => b.modified.getTime() - a.modified.getTime());
|
|
461
|
-
return {
|
|
462
|
-
success: true,
|
|
463
|
-
files: files,
|
|
464
|
-
count: files.length,
|
|
465
|
-
directory: outputDir,
|
|
466
|
-
message: `Found ${files.length} flow XML files`
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
catch (error) {
|
|
470
|
-
return {
|
|
471
|
-
success: false,
|
|
472
|
-
error: error instanceof Error ? error.message : String(error)
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Helper methods for examples
|
|
478
|
-
*/
|
|
479
|
-
getApprovalFlowExample() {
|
|
480
|
-
return {
|
|
481
|
-
name: 'Multi-Level Approval Flow',
|
|
482
|
-
description: 'Production-ready multi-level approval workflow',
|
|
483
|
-
internal_name: 'multi_level_approval',
|
|
484
|
-
table: 'sc_request',
|
|
485
|
-
trigger_type: 'record_created',
|
|
486
|
-
trigger_condition: 'approval=requested',
|
|
487
|
-
run_as: 'user',
|
|
488
|
-
activities: [
|
|
489
|
-
{
|
|
490
|
-
name: 'Manager Approval',
|
|
491
|
-
type: 'approval',
|
|
492
|
-
order: 100,
|
|
493
|
-
inputs: {
|
|
494
|
-
table: 'sc_request',
|
|
495
|
-
record: '{{trigger.current.sys_id}}',
|
|
496
|
-
approver: '{{trigger.current.requested_for.manager}}',
|
|
497
|
-
approval_field: 'approval',
|
|
498
|
-
message: 'Please approve request {{trigger.current.number}} for {{trigger.current.requested_for.name}}'
|
|
499
|
-
},
|
|
500
|
-
outputs: {
|
|
501
|
-
state: 'string',
|
|
502
|
-
approver_sys_id: 'string'
|
|
503
|
-
}
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
name: 'Director Approval',
|
|
507
|
-
type: 'approval',
|
|
508
|
-
order: 200,
|
|
509
|
-
condition: '{{manager_approval.state}} == "approved" && {{trigger.current.price}} > 5000',
|
|
510
|
-
inputs: {
|
|
511
|
-
table: 'sc_request',
|
|
512
|
-
record: '{{trigger.current.sys_id}}',
|
|
513
|
-
approver: '{{trigger.current.requested_for.manager.manager}}',
|
|
514
|
-
approval_field: 'approval',
|
|
515
|
-
message: 'High-value request requires director approval: {{trigger.current.number}}'
|
|
516
|
-
},
|
|
517
|
-
outputs: {
|
|
518
|
-
state: 'string',
|
|
519
|
-
approver_sys_id: 'string'
|
|
520
|
-
}
|
|
521
|
-
},
|
|
522
|
-
{
|
|
523
|
-
name: 'Send Result Notification',
|
|
524
|
-
type: 'notification',
|
|
525
|
-
order: 300,
|
|
526
|
-
inputs: {
|
|
527
|
-
notification_id: (0, servicenow_id_generator_js_1.getNotificationTemplateSysId)('generic_notification'),
|
|
528
|
-
recipients: '{{trigger.current.requested_for}}',
|
|
529
|
-
values: {
|
|
530
|
-
request_number: '{{trigger.current.number}}',
|
|
531
|
-
final_status: '{{director_approval.state || manager_approval.state}}'
|
|
532
|
-
}
|
|
533
|
-
},
|
|
534
|
-
outputs: {
|
|
535
|
-
sent: 'boolean'
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
]
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
getIncidentNotificationExample() {
|
|
542
|
-
return {
|
|
543
|
-
name: 'High Priority Incident Notification',
|
|
544
|
-
description: 'Notifies management of high priority incidents',
|
|
545
|
-
table: 'incident',
|
|
546
|
-
trigger_type: 'record_created',
|
|
547
|
-
trigger_condition: 'priority<=2',
|
|
548
|
-
activities: [
|
|
549
|
-
{
|
|
550
|
-
name: 'Check Business Hours',
|
|
551
|
-
type: 'script',
|
|
552
|
-
order: 100,
|
|
553
|
-
inputs: {
|
|
554
|
-
script: `
|
|
555
|
-
var isBusinessHours = gs.isBusinessHours();
|
|
556
|
-
current.u_notified_outside_hours = !isBusinessHours;
|
|
557
|
-
return { is_business_hours: isBusinessHours };
|
|
558
|
-
`.trim()
|
|
559
|
-
},
|
|
560
|
-
outputs: {
|
|
561
|
-
is_business_hours: 'boolean'
|
|
562
|
-
}
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
name: 'Send Management Alert',
|
|
566
|
-
type: 'notification',
|
|
567
|
-
order: 200,
|
|
568
|
-
inputs: {
|
|
569
|
-
recipient: 'it-management@company.com',
|
|
570
|
-
subject: 'URGENT: P${current.priority} Incident Created',
|
|
571
|
-
message: 'High priority incident ${current.number} requires attention'
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
name: 'Create War Room Task',
|
|
576
|
-
type: 'create_record',
|
|
577
|
-
order: 300,
|
|
578
|
-
condition: '${current.priority} == 1',
|
|
579
|
-
inputs: {
|
|
580
|
-
table: 'task',
|
|
581
|
-
fields: {
|
|
582
|
-
short_description: 'War Room: ${current.number}',
|
|
583
|
-
description: 'Coordinate response for critical incident',
|
|
584
|
-
assigned_to: '${current.assignment_group.manager}'
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
]
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
getEquipmentProvisioningExample() {
|
|
592
|
-
return {
|
|
593
|
-
name: 'IT Equipment Provisioning',
|
|
594
|
-
description: 'Automated provisioning of IT equipment',
|
|
595
|
-
table: 'sc_request',
|
|
596
|
-
trigger_type: 'record_updated',
|
|
597
|
-
trigger_condition: 'state=approved^cat_item.category=hardware',
|
|
598
|
-
activities: [
|
|
599
|
-
{
|
|
600
|
-
name: 'Check Inventory',
|
|
601
|
-
type: 'rest_step',
|
|
602
|
-
order: 100,
|
|
603
|
-
inputs: {
|
|
604
|
-
endpoint: '${system.property.inventory_api_url}/check',
|
|
605
|
-
method: 'POST',
|
|
606
|
-
headers: {
|
|
607
|
-
'Content-Type': 'application/json',
|
|
608
|
-
'Authorization': 'Bearer ${system.property.inventory_api_token}'
|
|
609
|
-
},
|
|
610
|
-
body: {
|
|
611
|
-
item_code: '${current.cat_item.model_number}',
|
|
612
|
-
quantity: '${current.quantity}'
|
|
613
|
-
}
|
|
614
|
-
},
|
|
615
|
-
outputs: {
|
|
616
|
-
in_stock: 'boolean',
|
|
617
|
-
available_quantity: 'integer'
|
|
618
|
-
}
|
|
619
|
-
},
|
|
620
|
-
{
|
|
621
|
-
name: 'Create Asset Record',
|
|
622
|
-
type: 'create_record',
|
|
623
|
-
order: 200,
|
|
624
|
-
condition: '${check_inventory.in_stock} == true',
|
|
625
|
-
inputs: {
|
|
626
|
-
table: 'alm_asset',
|
|
627
|
-
fields: {
|
|
628
|
-
display_name: '${current.cat_item.name} - ${current.requested_for.name}',
|
|
629
|
-
assigned_to: '${current.requested_for}',
|
|
630
|
-
state: 'In use',
|
|
631
|
-
po_number: '${current.number}'
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
name: 'Send Delivery Instructions',
|
|
637
|
-
type: 'notification',
|
|
638
|
-
order: 300,
|
|
639
|
-
inputs: {
|
|
640
|
-
recipient: '${current.requested_for.email}',
|
|
641
|
-
subject: 'Equipment Ready for Pickup',
|
|
642
|
-
message: 'Your ${current.cat_item.name} is ready. Pickup location: ${pickup_location}'
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
]
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
getDataProcessingExample() {
|
|
649
|
-
return {
|
|
650
|
-
name: 'Daily Data Processing',
|
|
651
|
-
description: 'Process and analyze daily operational data',
|
|
652
|
-
trigger_type: 'scheduled',
|
|
653
|
-
trigger_condition: '0 2 * * *', // 2 AM daily
|
|
654
|
-
activities: [
|
|
655
|
-
{
|
|
656
|
-
name: 'Extract Yesterday Data',
|
|
657
|
-
type: 'script',
|
|
658
|
-
order: 100,
|
|
659
|
-
inputs: {
|
|
660
|
-
script: `
|
|
661
|
-
var yesterday = new GlideDateTime();
|
|
662
|
-
yesterday.addDays(-1);
|
|
663
|
-
var gr = new GlideRecord('incident');
|
|
664
|
-
gr.addQuery('opened_at', '>=', yesterday.getDate());
|
|
665
|
-
gr.query();
|
|
666
|
-
var count = gr.getRowCount();
|
|
667
|
-
return { record_count: count, date: yesterday.getDate() };
|
|
668
|
-
`.trim()
|
|
669
|
-
},
|
|
670
|
-
outputs: {
|
|
671
|
-
record_count: 'integer',
|
|
672
|
-
date: 'string'
|
|
673
|
-
}
|
|
674
|
-
},
|
|
675
|
-
{
|
|
676
|
-
name: 'Generate Report',
|
|
677
|
-
type: 'script',
|
|
678
|
-
order: 200,
|
|
679
|
-
inputs: {
|
|
680
|
-
script: `
|
|
681
|
-
// Generate daily report logic
|
|
682
|
-
var report = generateDailyReport(current.record_count);
|
|
683
|
-
return { report_id: report.sys_id };
|
|
684
|
-
`.trim()
|
|
685
|
-
}
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
name: 'Send Report',
|
|
689
|
-
type: 'notification',
|
|
690
|
-
order: 300,
|
|
691
|
-
inputs: {
|
|
692
|
-
recipient: 'operations@company.com',
|
|
693
|
-
subject: 'Daily Operations Report - ${date}',
|
|
694
|
-
message: 'Daily report is ready. ${record_count} incidents processed.',
|
|
695
|
-
attachments: '${report_id}'
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
]
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
getUserOnboardingExample() {
|
|
702
|
-
return {
|
|
703
|
-
name: 'Employee Onboarding Workflow',
|
|
704
|
-
description: 'Automated onboarding process for new employees',
|
|
705
|
-
table: 'sys_user',
|
|
706
|
-
trigger_type: 'record_created',
|
|
707
|
-
trigger_condition: 'employee_number!=NULL',
|
|
708
|
-
activities: [
|
|
709
|
-
{
|
|
710
|
-
name: 'Create AD Account',
|
|
711
|
-
type: 'rest_step',
|
|
712
|
-
order: 100,
|
|
713
|
-
inputs: {
|
|
714
|
-
endpoint: '${system.property.ad_api_url}/users',
|
|
715
|
-
method: 'POST',
|
|
716
|
-
body: {
|
|
717
|
-
username: '${current.user_name}',
|
|
718
|
-
email: '${current.email}',
|
|
719
|
-
department: '${current.department}'
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
},
|
|
723
|
-
{
|
|
724
|
-
name: 'Assign Equipment',
|
|
725
|
-
type: 'create_record',
|
|
726
|
-
order: 200,
|
|
727
|
-
inputs: {
|
|
728
|
-
table: 'sc_request',
|
|
729
|
-
fields: {
|
|
730
|
-
requested_for: '${current.sys_id}',
|
|
731
|
-
cat_item: '${system.property.standard_laptop_item}',
|
|
732
|
-
short_description: 'New Employee Equipment - ${current.name}'
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
},
|
|
736
|
-
{
|
|
737
|
-
name: 'Schedule Training',
|
|
738
|
-
type: 'create_record',
|
|
739
|
-
order: 300,
|
|
740
|
-
inputs: {
|
|
741
|
-
table: 'task',
|
|
742
|
-
fields: {
|
|
743
|
-
short_description: 'Onboarding Training - ${current.name}',
|
|
744
|
-
assigned_to: '${current.department.training_coordinator}',
|
|
745
|
-
due_date: '+7 days'
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
},
|
|
749
|
-
{
|
|
750
|
-
name: 'Send Welcome Email',
|
|
751
|
-
type: 'notification',
|
|
752
|
-
order: 400,
|
|
753
|
-
inputs: {
|
|
754
|
-
recipient: '${current.email}',
|
|
755
|
-
cc: '${current.manager.email}',
|
|
756
|
-
subject: 'Welcome to the Team!',
|
|
757
|
-
message: 'Welcome ${current.first_name}! Your accounts are being set up.'
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
]
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* Helper methods
|
|
765
|
-
*/
|
|
766
|
-
mapTriggerType(type) {
|
|
767
|
-
const typeMap = {
|
|
768
|
-
'create': 'record_created',
|
|
769
|
-
'update': 'record_updated',
|
|
770
|
-
'manual': 'manual',
|
|
771
|
-
'scheduled': 'scheduled',
|
|
772
|
-
'cron': 'scheduled'
|
|
773
|
-
};
|
|
774
|
-
return typeMap[type.toLowerCase()] || 'manual';
|
|
775
|
-
}
|
|
776
|
-
convertToXMLActivities(requirements) {
|
|
777
|
-
const activities = [];
|
|
778
|
-
// Convert actions to activities
|
|
779
|
-
if (requirements.actions && Array.isArray(requirements.actions)) {
|
|
780
|
-
requirements.actions.forEach((action, index) => {
|
|
781
|
-
activities.push({
|
|
782
|
-
name: action.name || `Activity ${index + 1}`,
|
|
783
|
-
type: this.mapActionType(action.type || 'script'),
|
|
784
|
-
order: (index + 1) * 100,
|
|
785
|
-
inputs: action.config || action.inputs || {},
|
|
786
|
-
outputs: action.outputs,
|
|
787
|
-
condition: action.condition
|
|
788
|
-
});
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
// If no activities but has requirements, generate default activities
|
|
792
|
-
if (activities.length === 0 && requirements.description) {
|
|
793
|
-
activities.push({
|
|
794
|
-
name: 'Process Request',
|
|
795
|
-
type: 'script',
|
|
796
|
-
order: 100,
|
|
797
|
-
inputs: {
|
|
798
|
-
script: '// Process logic here\ngs.info("Processing: " + current.number);'
|
|
799
|
-
}
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
return activities;
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Convert requirements to IMPROVED activities (with enhanced structure)
|
|
806
|
-
*/
|
|
807
|
-
convertToImprovedActivities(requirements) {
|
|
808
|
-
const activities = [];
|
|
809
|
-
// Convert actions to improved activities
|
|
810
|
-
if (requirements.actions && Array.isArray(requirements.actions)) {
|
|
811
|
-
requirements.actions.forEach((action, index) => {
|
|
812
|
-
activities.push({
|
|
813
|
-
name: action.name || `Activity ${index + 1}`,
|
|
814
|
-
type: this.mapActionType(action.type || 'script'),
|
|
815
|
-
order: (index + 1) * 100,
|
|
816
|
-
inputs: action.config || action.inputs || {},
|
|
817
|
-
outputs: action.outputs,
|
|
818
|
-
condition: action.condition,
|
|
819
|
-
description: action.description || action.name || `Enhanced activity ${index + 1}`,
|
|
820
|
-
exit_conditions: action.exit_conditions || { success: true }
|
|
821
|
-
});
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
// If no activities but has requirements, generate default enhanced activities
|
|
825
|
-
if (activities.length === 0 && requirements.description) {
|
|
826
|
-
activities.push({
|
|
827
|
-
name: 'Process Request',
|
|
828
|
-
type: 'script',
|
|
829
|
-
order: 100,
|
|
830
|
-
description: 'Process the request with enhanced logging and error handling',
|
|
831
|
-
inputs: {
|
|
832
|
-
script: `// Enhanced processing logic
|
|
833
|
-
try {
|
|
834
|
-
gs.info("Processing request: " + current.number);
|
|
835
|
-
// Add your business logic here
|
|
836
|
-
return { success: true, message: "Request processed successfully" };
|
|
837
|
-
} catch (error) {
|
|
838
|
-
gs.error("Error processing request: " + error.message);
|
|
839
|
-
return { success: false, error: error.message };
|
|
840
|
-
}`,
|
|
841
|
-
timeout: 30
|
|
842
|
-
},
|
|
843
|
-
outputs: {
|
|
844
|
-
success: 'boolean',
|
|
845
|
-
message: 'string',
|
|
846
|
-
error: 'string'
|
|
847
|
-
},
|
|
848
|
-
exit_conditions: { success: true }
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
return activities;
|
|
852
|
-
}
|
|
853
|
-
mapActionType(type) {
|
|
854
|
-
const typeMap = {
|
|
855
|
-
'email': 'notification',
|
|
856
|
-
'notify': 'notification',
|
|
857
|
-
'approve': 'approval',
|
|
858
|
-
'script': 'script',
|
|
859
|
-
'create': 'create_record',
|
|
860
|
-
'update': 'update_record',
|
|
861
|
-
'rest': 'rest_step',
|
|
862
|
-
'api': 'rest_step'
|
|
863
|
-
};
|
|
864
|
-
return typeMap[type.toLowerCase()] || 'script';
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
* IMPROVED example methods (enhanced with better structure)
|
|
868
|
-
*/
|
|
869
|
-
getImprovedIncidentNotificationExample() {
|
|
870
|
-
return {
|
|
871
|
-
name: 'Enhanced High Priority Incident Notification',
|
|
872
|
-
description: 'Advanced notification system for high priority incidents with escalation logic',
|
|
873
|
-
table: 'incident',
|
|
874
|
-
trigger_type: 'record_created',
|
|
875
|
-
trigger_condition: 'priority<=2^active=true',
|
|
876
|
-
run_as: 'user',
|
|
877
|
-
accessible_from: 'package_private',
|
|
878
|
-
category: 'notification',
|
|
879
|
-
tags: ['incident', 'notification', 'escalation', 'high-priority'],
|
|
880
|
-
activities: [
|
|
881
|
-
{
|
|
882
|
-
name: 'Analyze Incident Severity',
|
|
883
|
-
type: 'script',
|
|
884
|
-
order: 100,
|
|
885
|
-
description: 'Comprehensive incident _analysis with business impact assessment',
|
|
886
|
-
inputs: {
|
|
887
|
-
script: `// Enhanced incident analysis
|
|
888
|
-
var _analysis = {
|
|
889
|
-
severity_score: 0,
|
|
890
|
-
business_impact: 'low',
|
|
891
|
-
escalation_required: false,
|
|
892
|
-
notification_channels: [],
|
|
893
|
-
estimated_resolution_time: '4 hours'
|
|
894
|
-
};
|
|
895
|
-
|
|
896
|
-
// Calculate severity score
|
|
897
|
-
if (current.priority == 1) _analysis.severity_score = 100;
|
|
898
|
-
else if (current.priority == 2) _analysis.severity_score = 80;
|
|
899
|
-
|
|
900
|
-
// Business impact assessment
|
|
901
|
-
if (current.category && current.category.toString().includes('business_critical')) {
|
|
902
|
-
_analysis.business_impact = 'critical';
|
|
903
|
-
_analysis.escalation_required = true;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
// Determine notification channels
|
|
907
|
-
_analysis.notification_channels = ['email'];
|
|
908
|
-
if (_analysis.severity_score >= 90) {
|
|
909
|
-
_analysis.notification_channels.push('sms', 'teams');
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
// Check for after-hours escalation
|
|
913
|
-
var isAfterHours = !gs.isBusinessHours();
|
|
914
|
-
if (isAfterHours && _analysis.severity_score >= 80) {
|
|
915
|
-
_analysis.escalation_required = true;
|
|
916
|
-
_analysis.notification_channels.push('emergency_contact');
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
return _analysis;`,
|
|
920
|
-
timeout: 30
|
|
921
|
-
},
|
|
922
|
-
outputs: {
|
|
923
|
-
severity_score: 'number',
|
|
924
|
-
business_impact: 'string',
|
|
925
|
-
escalation_required: 'boolean',
|
|
926
|
-
notification_channels: 'object',
|
|
927
|
-
estimated_resolution_time: 'string'
|
|
928
|
-
},
|
|
929
|
-
exit_conditions: { success: true }
|
|
930
|
-
},
|
|
931
|
-
{
|
|
932
|
-
name: 'Send Multi-Channel Notifications',
|
|
933
|
-
type: 'notification',
|
|
934
|
-
order: 200,
|
|
935
|
-
description: 'Send notifications via multiple channels based on severity',
|
|
936
|
-
inputs: {
|
|
937
|
-
recipients: '{{trigger.current.assignment_group.manager}},it-management@company.com',
|
|
938
|
-
cc: '{{trigger.current.caller_id}}',
|
|
939
|
-
subject: 'URGENT P{{trigger.current.priority}} Incident: {{trigger.current.short_description}}',
|
|
940
|
-
message: `High Priority Incident Alert
|
|
941
|
-
|
|
942
|
-
Incident: {{trigger.current.number}}
|
|
943
|
-
Priority: P{{trigger.current.priority}}
|
|
944
|
-
Severity Score: {{analyze_incident_severity.severity_score}}
|
|
945
|
-
Business Impact: {{analyze_incident_severity.business_impact}}
|
|
946
|
-
Category: {{trigger.current.category}}
|
|
947
|
-
Affected User: {{trigger.current.caller_id.name}}
|
|
948
|
-
Assignment Group: {{trigger.current.assignment_group.name}}
|
|
949
|
-
|
|
950
|
-
Short Description: {{trigger.current.short_description}}
|
|
951
|
-
|
|
952
|
-
Estimated Resolution: {{analyze_incident_severity.estimated_resolution_time}}
|
|
953
|
-
Escalation Required: {{analyze_incident_severity.escalation_required}}
|
|
954
|
-
|
|
955
|
-
Please take immediate action to resolve this incident.
|
|
956
|
-
|
|
957
|
-
View Incident: {{sys.url_base}}/incident.do?sys_id={{trigger.current.sys_id}}`,
|
|
958
|
-
notification_type: 'urgent',
|
|
959
|
-
channels: '{{analyze_incident_severity.notification_channels}}'
|
|
960
|
-
},
|
|
961
|
-
outputs: {
|
|
962
|
-
sent: 'boolean',
|
|
963
|
-
channels_used: 'object',
|
|
964
|
-
notification_id: 'string'
|
|
965
|
-
},
|
|
966
|
-
exit_conditions: { success: true }
|
|
967
|
-
},
|
|
968
|
-
{
|
|
969
|
-
name: 'Create Emergency Response Task',
|
|
970
|
-
type: 'create_record',
|
|
971
|
-
order: 300,
|
|
972
|
-
description: 'Create emergency response coordination task for critical incidents',
|
|
973
|
-
condition: '{{analyze_incident_severity.escalation_required}} == true',
|
|
974
|
-
inputs: {
|
|
975
|
-
table: 'task',
|
|
976
|
-
fields: [
|
|
977
|
-
{
|
|
978
|
-
field: 'short_description',
|
|
979
|
-
value: 'EMERGENCY RESPONSE: {{trigger.current.number}} - {{trigger.current.short_description}}'
|
|
980
|
-
},
|
|
981
|
-
{
|
|
982
|
-
field: 'description',
|
|
983
|
-
value: `Emergency Response Coordination
|
|
984
|
-
|
|
985
|
-
Related Incident: {{trigger.current.number}}
|
|
986
|
-
Severity Score: {{analyze_incident_severity.severity_score}}
|
|
987
|
-
Business Impact: {{analyze_incident_severity.business_impact}}
|
|
988
|
-
Channels Notified: {{send_multi_channel_notifications.channels_used}}
|
|
989
|
-
|
|
990
|
-
Actions Required:
|
|
991
|
-
1. Establish incident command center
|
|
992
|
-
2. Coordinate with technical teams
|
|
993
|
-
3. Prepare stakeholder communications
|
|
994
|
-
4. Monitor resolution progress
|
|
995
|
-
|
|
996
|
-
Escalation Triggered: {{sys.now}}`
|
|
997
|
-
},
|
|
998
|
-
{ field: 'priority', value: '1' },
|
|
999
|
-
{ field: 'assignment_group', value: 'incident_management' },
|
|
1000
|
-
{ field: 'parent', value: '{{trigger.current.sys_id}}' },
|
|
1001
|
-
{ field: 'due_date', value: '+1 hour' },
|
|
1002
|
-
{ field: 'work_notes', value: 'Auto-created for emergency incident response coordination' }
|
|
1003
|
-
]
|
|
1004
|
-
},
|
|
1005
|
-
outputs: {
|
|
1006
|
-
task_sys_id: 'string',
|
|
1007
|
-
task_number: 'string',
|
|
1008
|
-
assigned_to: 'string'
|
|
1009
|
-
},
|
|
1010
|
-
exit_conditions: { success: true }
|
|
1011
|
-
}
|
|
1012
|
-
]
|
|
1013
|
-
};
|
|
1014
|
-
}
|
|
1015
|
-
getImprovedEquipmentProvisioningExample() {
|
|
1016
|
-
return {
|
|
1017
|
-
name: 'Advanced IT Equipment Provisioning',
|
|
1018
|
-
description: 'Comprehensive equipment provisioning with inventory management and asset tracking',
|
|
1019
|
-
table: 'sc_request',
|
|
1020
|
-
trigger_type: 'record_updated',
|
|
1021
|
-
trigger_condition: 'state=approved^cat_item.category=hardware^active=true',
|
|
1022
|
-
run_as: 'user',
|
|
1023
|
-
accessible_from: 'package_private',
|
|
1024
|
-
category: 'provisioning',
|
|
1025
|
-
tags: ['equipment', 'provisioning', 'inventory', 'asset-management'],
|
|
1026
|
-
activities: [
|
|
1027
|
-
{
|
|
1028
|
-
name: 'Enhanced Inventory Check',
|
|
1029
|
-
type: 'script',
|
|
1030
|
-
order: 100,
|
|
1031
|
-
description: 'Comprehensive inventory check with alternative options',
|
|
1032
|
-
inputs: {
|
|
1033
|
-
script: `// Advanced inventory management
|
|
1034
|
-
var inventoryCheck = {
|
|
1035
|
-
primary_item_available: false,
|
|
1036
|
-
alternative_options: [],
|
|
1037
|
-
delivery_estimate: '',
|
|
1038
|
-
procurement_required: false,
|
|
1039
|
-
total_cost: 0
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
// Check primary item availability
|
|
1043
|
-
var itemGR = new GlideRecord('alm_consumable');
|
|
1044
|
-
itemGR.addQuery('model_number', current.cat_item.model_number);
|
|
1045
|
-
itemGR.query();
|
|
1046
|
-
|
|
1047
|
-
if (itemGR.next()) {
|
|
1048
|
-
var availableQty = parseInt(itemGR.quantity);
|
|
1049
|
-
var requestedQty = parseInt(current.quantity || 1);
|
|
1050
|
-
|
|
1051
|
-
if (availableQty >= requestedQty) {
|
|
1052
|
-
inventoryCheck.primary_item_available = true;
|
|
1053
|
-
inventoryCheck.delivery_estimate = '2-3 business days';
|
|
1054
|
-
} else {
|
|
1055
|
-
// Find alternatives
|
|
1056
|
-
var altGR = new GlideRecord('alm_consumable');
|
|
1057
|
-
altGR.addQuery('category', itemGR.category);
|
|
1058
|
-
altGR.addQuery('quantity', '>', requestedQty);
|
|
1059
|
-
altGR.query();
|
|
1060
|
-
|
|
1061
|
-
while (altGR.next() && inventoryCheck.alternative_options.length < 3) {
|
|
1062
|
-
inventoryCheck.alternative_options.push({
|
|
1063
|
-
name: altGR.display_name.toString(),
|
|
1064
|
-
model: altGR.model_number.toString(),
|
|
1065
|
-
quantity: altGR.quantity.toString(),
|
|
1066
|
-
cost: altGR.cost.toString()
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
if (inventoryCheck.alternative_options.length === 0) {
|
|
1071
|
-
inventoryCheck.procurement_required = true;
|
|
1072
|
-
inventoryCheck.delivery_estimate = '10-15 business days';
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
return inventoryCheck;`,
|
|
1078
|
-
timeout: 60
|
|
1079
|
-
},
|
|
1080
|
-
outputs: {
|
|
1081
|
-
primary_item_available: 'boolean',
|
|
1082
|
-
alternative_options: 'object',
|
|
1083
|
-
delivery_estimate: 'string',
|
|
1084
|
-
procurement_required: 'boolean',
|
|
1085
|
-
total_cost: 'number'
|
|
1086
|
-
},
|
|
1087
|
-
exit_conditions: { success: true }
|
|
1088
|
-
},
|
|
1089
|
-
{
|
|
1090
|
-
name: 'Create Comprehensive Asset Record',
|
|
1091
|
-
type: 'create_record',
|
|
1092
|
-
order: 200,
|
|
1093
|
-
description: 'Create detailed asset record with full lifecycle tracking',
|
|
1094
|
-
condition: '{{enhanced_inventory_check.primary_item_available}} == true',
|
|
1095
|
-
inputs: {
|
|
1096
|
-
table: 'alm_asset',
|
|
1097
|
-
fields: [
|
|
1098
|
-
{
|
|
1099
|
-
field: 'display_name',
|
|
1100
|
-
value: '{{trigger.current.cat_item.name}} - {{trigger.current.requested_for.name}}'
|
|
1101
|
-
},
|
|
1102
|
-
{ field: 'assigned_to', value: '{{trigger.current.requested_for}}' },
|
|
1103
|
-
{ field: 'state', value: 'On order' },
|
|
1104
|
-
{ field: 'substatus', value: 'Approved for deployment' },
|
|
1105
|
-
{ field: 'po_number', value: '{{trigger.current.number}}' },
|
|
1106
|
-
{ field: 'cost', value: '{{trigger.current.price}}' },
|
|
1107
|
-
{ field: 'delivery_date', value: '{{enhanced_inventory_check.delivery_estimate}}' },
|
|
1108
|
-
{ field: 'location', value: '{{trigger.current.requested_for.location}}' },
|
|
1109
|
-
{ field: 'department', value: '{{trigger.current.requested_for.department}}' },
|
|
1110
|
-
{ field: 'justification', value: '{{trigger.current.business_justification}}' },
|
|
1111
|
-
{
|
|
1112
|
-
field: 'work_notes',
|
|
1113
|
-
value: 'Asset provisioned via automated workflow. Request: {{trigger.current.number}}. Delivery estimate: {{enhanced_inventory_check.delivery_estimate}}'
|
|
1114
|
-
}
|
|
1115
|
-
]
|
|
1116
|
-
},
|
|
1117
|
-
outputs: {
|
|
1118
|
-
asset_sys_id: 'string',
|
|
1119
|
-
asset_tag: 'string',
|
|
1120
|
-
tracking_number: 'string'
|
|
1121
|
-
},
|
|
1122
|
-
exit_conditions: { success: true }
|
|
1123
|
-
},
|
|
1124
|
-
{
|
|
1125
|
-
name: 'Send Enhanced Delivery Notification',
|
|
1126
|
-
type: 'notification',
|
|
1127
|
-
order: 300,
|
|
1128
|
-
description: 'Comprehensive delivery notification with tracking information',
|
|
1129
|
-
inputs: {
|
|
1130
|
-
recipients: '{{trigger.current.requested_for}}',
|
|
1131
|
-
cc: '{{trigger.current.requested_for.manager}},{{trigger.current.opened_by}}',
|
|
1132
|
-
subject: 'Equipment Approved & Scheduled for Delivery - {{trigger.current.number}}',
|
|
1133
|
-
message: `Equipment Provisioning Update
|
|
1134
|
-
|
|
1135
|
-
Request Details:
|
|
1136
|
-
- Request Number: {{trigger.current.number}}
|
|
1137
|
-
- Item: {{trigger.current.cat_item.name}}
|
|
1138
|
-
- Status: Approved and scheduled for delivery
|
|
1139
|
-
- Asset Tag: {{create_comprehensive_asset_record.asset_tag}}
|
|
1140
|
-
|
|
1141
|
-
Delivery Information:
|
|
1142
|
-
- Estimated Delivery: {{enhanced_inventory_check.delivery_estimate}}
|
|
1143
|
-
- Delivery Location: {{trigger.current.requested_for.location.name}}
|
|
1144
|
-
- Tracking Number: {{create_comprehensive_asset_record.tracking_number}}
|
|
1145
|
-
|
|
1146
|
-
Next Steps:
|
|
1147
|
-
1. You will receive a delivery confirmation email
|
|
1148
|
-
2. Please be available during business hours for delivery
|
|
1149
|
-
3. Asset setup appointment will be scheduled separately if required
|
|
1150
|
-
|
|
1151
|
-
Important Notes:
|
|
1152
|
-
- Please have your employee ID ready for delivery verification
|
|
1153
|
-
- Any delivery issues should be reported to IT Service Desk immediately
|
|
1154
|
-
- Training materials will be provided with your equipment
|
|
1155
|
-
|
|
1156
|
-
For questions or concerns, please contact:
|
|
1157
|
-
IT Service Desk: {{sys.property.it_service_desk_phone}}
|
|
1158
|
-
Email: {{sys.property.it_service_desk_email}}
|
|
1159
|
-
|
|
1160
|
-
Thank you!
|
|
1161
|
-
IT Service Management Team`,
|
|
1162
|
-
notification_type: 'information',
|
|
1163
|
-
attachments: '{{create_comprehensive_asset_record.asset_sys_id}}'
|
|
1164
|
-
},
|
|
1165
|
-
outputs: {
|
|
1166
|
-
sent: 'boolean',
|
|
1167
|
-
delivery_confirmed: 'boolean',
|
|
1168
|
-
notification_id: 'string'
|
|
1169
|
-
},
|
|
1170
|
-
exit_conditions: { success: true }
|
|
1171
|
-
}
|
|
1172
|
-
]
|
|
1173
|
-
};
|
|
1174
|
-
}
|
|
1175
|
-
getImprovedDataProcessingExample() {
|
|
1176
|
-
return {
|
|
1177
|
-
name: 'Advanced Daily Data Processing & Analytics',
|
|
1178
|
-
description: 'Comprehensive data processing with analytics, reporting, and alerting',
|
|
1179
|
-
trigger_type: 'scheduled',
|
|
1180
|
-
trigger_condition: '0 2 * * *', // 2 AM daily
|
|
1181
|
-
run_as: 'system',
|
|
1182
|
-
accessible_from: 'private',
|
|
1183
|
-
category: 'automation',
|
|
1184
|
-
tags: ['data-processing', 'analytics', 'reporting', 'scheduled'],
|
|
1185
|
-
activities: [
|
|
1186
|
-
{
|
|
1187
|
-
name: 'Comprehensive Data Extraction',
|
|
1188
|
-
type: 'script',
|
|
1189
|
-
order: 100,
|
|
1190
|
-
description: 'Extract and process data from multiple sources with validation',
|
|
1191
|
-
inputs: {
|
|
1192
|
-
script: `// Advanced data extraction and processing
|
|
1193
|
-
var processingResults = {
|
|
1194
|
-
extraction_timestamp: new GlideDateTime().toString(),
|
|
1195
|
-
datasets: {},
|
|
1196
|
-
validation_errors: [],
|
|
1197
|
-
processing_summary: {},
|
|
1198
|
-
recommendations: []
|
|
1199
|
-
};
|
|
1200
|
-
|
|
1201
|
-
// Extract incidents data
|
|
1202
|
-
var incidentGR = new GlideRecord('incident');
|
|
1203
|
-
var yesterday = new GlideDateTime();
|
|
1204
|
-
yesterday.addDays(-1);
|
|
1205
|
-
incidentGR.addQuery('opened_at', '>=', yesterday.getDate());
|
|
1206
|
-
incidentGR.query();
|
|
1207
|
-
|
|
1208
|
-
var incidentData = {
|
|
1209
|
-
total_count: incidentGR.getRowCount(),
|
|
1210
|
-
priority_breakdown: { p1: 0, p2: 0, p3: 0, p4: 0 },
|
|
1211
|
-
category_breakdown: {},
|
|
1212
|
-
resolution_times: []
|
|
1213
|
-
};
|
|
1214
|
-
|
|
1215
|
-
while (incidentGR.next()) {
|
|
1216
|
-
// Priority analysis
|
|
1217
|
-
var priority = 'p' + incidentGR.priority;
|
|
1218
|
-
incidentData.priority_breakdown[priority]++;
|
|
1219
|
-
|
|
1220
|
-
// Category analysis
|
|
1221
|
-
var category = incidentGR.category.toString();
|
|
1222
|
-
if (!incidentData.category_breakdown[category]) {
|
|
1223
|
-
incidentData.category_breakdown[category] = 0;
|
|
1224
|
-
}
|
|
1225
|
-
incidentData.category_breakdown[category]++;
|
|
1226
|
-
|
|
1227
|
-
// Resolution time analysis
|
|
1228
|
-
if (incidentGR.resolved_at) {
|
|
1229
|
-
var openTime = new GlideDateTime(incidentGR.opened_at);
|
|
1230
|
-
var resolveTime = new GlideDateTime(incidentGR.resolved_at);
|
|
1231
|
-
var duration = resolveTime.getNumericValue() - openTime.getNumericValue();
|
|
1232
|
-
incidentData.resolution_times.push(duration);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
processingResults.datasets.incidents = incidentData;
|
|
1237
|
-
|
|
1238
|
-
// Extract service requests data
|
|
1239
|
-
var requestGR = new GlideRecord('sc_request');
|
|
1240
|
-
requestGR.addQuery('opened_at', '>=', yesterday.getDate());
|
|
1241
|
-
requestGR.query();
|
|
1242
|
-
|
|
1243
|
-
var requestData = {
|
|
1244
|
-
total_count: requestGR.getRowCount(),
|
|
1245
|
-
state_breakdown: {},
|
|
1246
|
-
fulfillment_times: []
|
|
1247
|
-
};
|
|
1248
|
-
|
|
1249
|
-
while (requestGR.next()) {
|
|
1250
|
-
var state = requestGR.state.getDisplayValue();
|
|
1251
|
-
if (!requestData.state_breakdown[state]) {
|
|
1252
|
-
requestData.state_breakdown[state] = 0;
|
|
1253
|
-
}
|
|
1254
|
-
requestData.state_breakdown[state]++;
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
processingResults.datasets.requests = requestData;
|
|
1258
|
-
|
|
1259
|
-
// Generate insights and recommendations
|
|
1260
|
-
if (incidentData.priority_breakdown.p1 > 5) {
|
|
1261
|
-
processingResults.recommendations.push('High number of P1 incidents detected. Consider incident management review.');
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
if (incidentData.total_count > 50) {
|
|
1265
|
-
processingResults.recommendations.push('Incident volume above threshold. Monitor for trends.');
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
return processingResults;`,
|
|
1269
|
-
timeout: 300
|
|
1270
|
-
},
|
|
1271
|
-
outputs: {
|
|
1272
|
-
extraction_timestamp: 'string',
|
|
1273
|
-
datasets: 'object',
|
|
1274
|
-
validation_errors: 'object',
|
|
1275
|
-
processing_summary: 'object',
|
|
1276
|
-
recommendations: 'object'
|
|
1277
|
-
},
|
|
1278
|
-
exit_conditions: { success: true }
|
|
1279
|
-
},
|
|
1280
|
-
{
|
|
1281
|
-
name: 'Generate Advanced Analytics Report',
|
|
1282
|
-
type: 'script',
|
|
1283
|
-
order: 200,
|
|
1284
|
-
description: 'Create comprehensive analytics report with visualizations',
|
|
1285
|
-
inputs: {
|
|
1286
|
-
script: `// Advanced report generation
|
|
1287
|
-
var reportData = {
|
|
1288
|
-
report_id: gs.generateGUID(),
|
|
1289
|
-
generated_at: new GlideDateTime().toString(),
|
|
1290
|
-
metrics: {},
|
|
1291
|
-
charts: {},
|
|
1292
|
-
alerts: [],
|
|
1293
|
-
export_ready: false
|
|
1294
|
-
};
|
|
1295
|
-
|
|
1296
|
-
var datasets = JSON.parse(current.datasets || '{}');
|
|
1297
|
-
|
|
1298
|
-
// Calculate key metrics
|
|
1299
|
-
if (datasets.incidents) {
|
|
1300
|
-
reportData.metrics.incident_volume_trend = calculateTrend(datasets.incidents.total_count);
|
|
1301
|
-
reportData.metrics.avg_resolution_time = calculateAverage(datasets.incidents.resolution_times);
|
|
1302
|
-
reportData.metrics.priority_distribution = datasets.incidents.priority_breakdown;
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
if (datasets.requests) {
|
|
1306
|
-
reportData.metrics.request_volume = datasets.requests.total_count;
|
|
1307
|
-
reportData.metrics.fulfillment_rate = calculateFulfillmentRate(datasets.requests.state_breakdown);
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
// Generate alerts for anomalies
|
|
1311
|
-
if (reportData.metrics.incident_volume_trend > 20) {
|
|
1312
|
-
reportData.alerts.push({
|
|
1313
|
-
type: 'warning',
|
|
1314
|
-
message: 'Incident volume increased by ' + reportData.metrics.incident_volume_trend + '%'
|
|
1315
|
-
});
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
// Create chart data
|
|
1319
|
-
reportData.charts.incident_trend = generateTrendChart(datasets.incidents);
|
|
1320
|
-
reportData.charts.priority_pie = generatePieChart(datasets.incidents.priority_breakdown);
|
|
1321
|
-
|
|
1322
|
-
reportData.export_ready = true;
|
|
1323
|
-
|
|
1324
|
-
function calculateTrend(currentValue) {
|
|
1325
|
-
// Simplified trend calculation
|
|
1326
|
-
return Math.floor(Math.random() * 30) - 10; // Placeholder
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
function calculateAverage(values) {
|
|
1330
|
-
if (!values || values.length === 0) return 0;
|
|
1331
|
-
var sum = values.reduce(function(a, b) { return a + b; }, 0);
|
|
1332
|
-
return Math.round(sum / values.length / 3600000); // Convert to hours
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
function calculateFulfillmentRate(stateBreakdown) {
|
|
1336
|
-
var completed = stateBreakdown['Completed'] || 0;
|
|
1337
|
-
var total = Object.values(stateBreakdown).reduce(function(a, b) { return a + b; }, 0);
|
|
1338
|
-
return total > 0 ? Math.round((completed / total) * 100) : 0;
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
function generateTrendChart(data) {
|
|
1342
|
-
return { type: 'line', data: data.priority_breakdown };
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
function generatePieChart(data) {
|
|
1346
|
-
return { type: 'pie', data: data };
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
return reportData;`,
|
|
1350
|
-
timeout: 180
|
|
1351
|
-
},
|
|
1352
|
-
outputs: {
|
|
1353
|
-
report_id: 'string',
|
|
1354
|
-
generated_at: 'string',
|
|
1355
|
-
metrics: 'object',
|
|
1356
|
-
charts: 'object',
|
|
1357
|
-
alerts: 'object',
|
|
1358
|
-
export_ready: 'boolean'
|
|
1359
|
-
},
|
|
1360
|
-
exit_conditions: { success: true }
|
|
1361
|
-
},
|
|
1362
|
-
{
|
|
1363
|
-
name: 'Send Comprehensive Analytics Report',
|
|
1364
|
-
type: 'notification',
|
|
1365
|
-
order: 300,
|
|
1366
|
-
description: 'Distribute detailed analytics report to stakeholders',
|
|
1367
|
-
inputs: {
|
|
1368
|
-
recipients: 'operations@company.com,it-management@company.com',
|
|
1369
|
-
cc: 'service-desk@company.com',
|
|
1370
|
-
subject: 'Daily Operations Analytics Report - {{comprehensive_data_extraction.extraction_timestamp}}',
|
|
1371
|
-
message: `Daily Operations Analytics Report
|
|
1372
|
-
|
|
1373
|
-
Report Generated: {{generate_advanced_analytics_report.generated_at}}
|
|
1374
|
-
Report ID: {{generate_advanced_analytics_report.report_id}}
|
|
1375
|
-
|
|
1376
|
-
== KEY METRICS ==
|
|
1377
|
-
Incident Volume: {{comprehensive_data_extraction.datasets.incidents.total_count}}
|
|
1378
|
-
Request Volume: {{comprehensive_data_extraction.datasets.requests.total_count}}
|
|
1379
|
-
Average Resolution Time: {{generate_advanced_analytics_report.metrics.avg_resolution_time}} hours
|
|
1380
|
-
Fulfillment Rate: {{generate_advanced_analytics_report.metrics.fulfillment_rate}}%
|
|
1381
|
-
|
|
1382
|
-
== PRIORITY BREAKDOWN ==
|
|
1383
|
-
P1 Incidents: {{comprehensive_data_extraction.datasets.incidents.priority_breakdown.p1}}
|
|
1384
|
-
P2 Incidents: {{comprehensive_data_extraction.datasets.incidents.priority_breakdown.p2}}
|
|
1385
|
-
P3 Incidents: {{comprehensive_data_extraction.datasets.incidents.priority_breakdown.p3}}
|
|
1386
|
-
P4 Incidents: {{comprehensive_data_extraction.datasets.incidents.priority_breakdown.p4}}
|
|
1387
|
-
|
|
1388
|
-
== ALERTS & RECOMMENDATIONS ==
|
|
1389
|
-
{{#each generate_advanced_analytics_report.alerts}}
|
|
1390
|
-
⚠️ {{this.message}}
|
|
1391
|
-
{{/each}}
|
|
1392
|
-
|
|
1393
|
-
{{#each comprehensive_data_extraction.recommendations}}
|
|
1394
|
-
💡 {{this}}
|
|
1395
|
-
{{/each}}
|
|
1396
|
-
|
|
1397
|
-
== DATA QUALITY ==
|
|
1398
|
-
Validation Errors: {{comprehensive_data_extraction.validation_errors.length}}
|
|
1399
|
-
Processing Status: Complete
|
|
1400
|
-
|
|
1401
|
-
Access full report dashboard: {{sys.url_base}}/analytics_dashboard.do?report={{generate_advanced_analytics_report.report_id}}
|
|
1402
|
-
|
|
1403
|
-
Next Report: Tomorrow at 2:00 AM
|
|
1404
|
-
|
|
1405
|
-
---
|
|
1406
|
-
Generated by ServiceNow Automated Analytics
|
|
1407
|
-
Questions? Contact IT Operations Team`,
|
|
1408
|
-
notification_type: 'daily_report',
|
|
1409
|
-
priority: 'normal'
|
|
1410
|
-
},
|
|
1411
|
-
outputs: {
|
|
1412
|
-
sent: 'boolean',
|
|
1413
|
-
report_distributed: 'boolean',
|
|
1414
|
-
notification_id: 'string'
|
|
1415
|
-
},
|
|
1416
|
-
exit_conditions: { success: true }
|
|
1417
|
-
}
|
|
1418
|
-
]
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
getImprovedUserOnboardingExample() {
|
|
1422
|
-
return {
|
|
1423
|
-
name: 'Comprehensive Employee Onboarding Workflow',
|
|
1424
|
-
description: 'End-to-end automated onboarding with multi-system integration and tracking',
|
|
1425
|
-
table: 'sys_user',
|
|
1426
|
-
trigger_type: 'record_created',
|
|
1427
|
-
trigger_condition: 'employee_number!=NULL^active=true^internal_type=employee',
|
|
1428
|
-
run_as: 'system',
|
|
1429
|
-
accessible_from: 'package_private',
|
|
1430
|
-
category: 'onboarding',
|
|
1431
|
-
tags: ['onboarding', 'employee', 'automation', 'integration'],
|
|
1432
|
-
activities: [
|
|
1433
|
-
{
|
|
1434
|
-
name: 'Comprehensive User Account Setup',
|
|
1435
|
-
type: 'script',
|
|
1436
|
-
order: 100,
|
|
1437
|
-
description: 'Complete user account provisioning with role assignment and access control',
|
|
1438
|
-
inputs: {
|
|
1439
|
-
script: `// Comprehensive onboarding setup
|
|
1440
|
-
var onboardingResults = {
|
|
1441
|
-
user_sys_id: current.sys_id,
|
|
1442
|
-
account_setup: {},
|
|
1443
|
-
role_assignments: [],
|
|
1444
|
-
access_requests: [],
|
|
1445
|
-
setup_errors: [],
|
|
1446
|
-
completion_status: 'in_progress'
|
|
1447
|
-
};
|
|
1448
|
-
|
|
1449
|
-
try {
|
|
1450
|
-
// Set up basic user attributes
|
|
1451
|
-
current.employee_number = current.employee_number || generateEmployeeNumber();
|
|
1452
|
-
current.user_name = current.user_name || generateUsername(current.first_name, current.last_name);
|
|
1453
|
-
current.email = current.email || (current.user_name + '@company.com');
|
|
1454
|
-
current.active = true;
|
|
1455
|
-
current.locked_out = false;
|
|
1456
|
-
|
|
1457
|
-
// Assign default roles based on department
|
|
1458
|
-
var defaultRoles = getDepartmentRoles(current.department.toString());
|
|
1459
|
-
defaultRoles.forEach(function(role) {
|
|
1460
|
-
var userRoleGR = new GlideRecord('sys_user_has_role');
|
|
1461
|
-
userRoleGR.user = current.sys_id;
|
|
1462
|
-
userRoleGR.role = role.sys_id;
|
|
1463
|
-
userRoleGR.insert();
|
|
1464
|
-
onboardingResults.role_assignments.push(role.name);
|
|
1465
|
-
});
|
|
1466
|
-
|
|
1467
|
-
// Create access requests for department-specific systems
|
|
1468
|
-
var accessSystems = getDepartmentSystems(current.department.toString());
|
|
1469
|
-
accessSystems.forEach(function(system) {
|
|
1470
|
-
var accessReqGR = new GlideRecord('access_request');
|
|
1471
|
-
accessReqGR.user = current.sys_id;
|
|
1472
|
-
accessReqGR.system = system.sys_id;
|
|
1473
|
-
accessReqGR.requested_by = current.manager;
|
|
1474
|
-
accessReqGR.business_justification = 'New employee onboarding';
|
|
1475
|
-
accessReqGR.state = 'pending_approval';
|
|
1476
|
-
var reqSysId = accessReqGR.insert();
|
|
1477
|
-
onboardingResults.access_requests.push({
|
|
1478
|
-
system: system.name,
|
|
1479
|
-
request_id: reqSysId
|
|
1480
|
-
});
|
|
1481
|
-
});
|
|
1482
|
-
|
|
1483
|
-
onboardingResults.account_setup.username = current.user_name;
|
|
1484
|
-
onboardingResults.account_setup.email = current.email;
|
|
1485
|
-
onboardingResults.account_setup.employee_number = current.employee_number;
|
|
1486
|
-
onboardingResults.completion_status = 'completed';
|
|
1487
|
-
|
|
1488
|
-
} catch (error) {
|
|
1489
|
-
onboardingResults.setup_errors.push(error.message);
|
|
1490
|
-
onboardingResults.completion_status = 'failed';
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
function generateEmployeeNumber() {
|
|
1494
|
-
return 'EMP' + Date.now().toString().substr(-6);
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
function generateUsername(firstName, lastName) {
|
|
1498
|
-
return (firstName.charAt(0) + lastName).toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
function getDepartmentRoles(department) {
|
|
1502
|
-
// Simplified role mapping
|
|
1503
|
-
var roleMap = {
|
|
1504
|
-
'IT': [{ sys_id: 'role1', name: 'itil' }, { sys_id: 'role2', name: 'catalog_editor' }],
|
|
1505
|
-
'HR': [{ sys_id: 'role3', name: 'hr_admin' }],
|
|
1506
|
-
'Finance': [{ sys_id: 'role4', name: 'finance_user' }]
|
|
1507
|
-
};
|
|
1508
|
-
return roleMap[department] || [{ sys_id: 'role5', name: 'employee' }];
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
function getDepartmentSystems(department) {
|
|
1512
|
-
// Simplified system mapping
|
|
1513
|
-
var systemMap = {
|
|
1514
|
-
'IT': [{ sys_id: 'sys1', name: 'ServiceNow Admin' }, { sys_id: 'sys2', name: 'Network Management' }],
|
|
1515
|
-
'HR': [{ sys_id: 'sys3', name: 'HRIS System' }],
|
|
1516
|
-
'Finance': [{ sys_id: 'sys4', name: 'ERP System' }]
|
|
1517
|
-
};
|
|
1518
|
-
return systemMap[department] || [];
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
return onboardingResults;`,
|
|
1522
|
-
timeout: 120
|
|
1523
|
-
},
|
|
1524
|
-
outputs: {
|
|
1525
|
-
user_sys_id: 'string',
|
|
1526
|
-
account_setup: 'object',
|
|
1527
|
-
role_assignments: 'object',
|
|
1528
|
-
access_requests: 'object',
|
|
1529
|
-
setup_errors: 'object',
|
|
1530
|
-
completion_status: 'string'
|
|
1531
|
-
},
|
|
1532
|
-
exit_conditions: { success: true }
|
|
1533
|
-
},
|
|
1534
|
-
{
|
|
1535
|
-
name: 'Equipment & Workspace Provisioning',
|
|
1536
|
-
type: 'create_record',
|
|
1537
|
-
order: 200,
|
|
1538
|
-
description: 'Automated equipment request and workspace setup',
|
|
1539
|
-
condition: '{{comprehensive_user_account_setup.completion_status}} == "completed"',
|
|
1540
|
-
inputs: {
|
|
1541
|
-
table: 'sc_request',
|
|
1542
|
-
fields: [
|
|
1543
|
-
{
|
|
1544
|
-
field: 'requested_for',
|
|
1545
|
-
value: '{{trigger.current.sys_id}}'
|
|
1546
|
-
},
|
|
1547
|
-
{
|
|
1548
|
-
field: 'cat_item',
|
|
1549
|
-
value: '{{sys.property.standard_employee_package}}'
|
|
1550
|
-
},
|
|
1551
|
-
{
|
|
1552
|
-
field: 'short_description',
|
|
1553
|
-
value: 'New Employee Equipment Package - {{trigger.current.first_name}} {{trigger.current.last_name}}'
|
|
1554
|
-
},
|
|
1555
|
-
{
|
|
1556
|
-
field: 'description',
|
|
1557
|
-
value: `Comprehensive equipment package for new employee:
|
|
1558
|
-
|
|
1559
|
-
Employee Details:
|
|
1560
|
-
- Name: {{trigger.current.first_name}} {{trigger.current.last_name}}
|
|
1561
|
-
- Employee Number: {{comprehensive_user_account_setup.account_setup.employee_number}}
|
|
1562
|
-
- Department: {{trigger.current.department.name}}
|
|
1563
|
-
- Location: {{trigger.current.location.name}}
|
|
1564
|
-
- Manager: {{trigger.current.manager.name}}
|
|
1565
|
-
- Start Date: {{trigger.current.start_date}}
|
|
1566
|
-
|
|
1567
|
-
Equipment Package Includes:
|
|
1568
|
-
- Standard laptop configuration
|
|
1569
|
-
- Monitor and accessories
|
|
1570
|
-
- Mobile device (if applicable)
|
|
1571
|
-
- Security badge and access card
|
|
1572
|
-
- Office supplies starter kit
|
|
1573
|
-
|
|
1574
|
-
Workspace Setup:
|
|
1575
|
-
- Desk assignment in {{trigger.current.location.name}}
|
|
1576
|
-
- Phone extension setup
|
|
1577
|
-
- Parking assignment (if applicable)
|
|
1578
|
-
- Building access configuration
|
|
1579
|
-
|
|
1580
|
-
Special Requirements:
|
|
1581
|
-
{{trigger.current.special_requirements}}
|
|
1582
|
-
|
|
1583
|
-
Delivery Target: {{trigger.current.start_date}}`
|
|
1584
|
-
},
|
|
1585
|
-
{ field: 'priority', value: '3' },
|
|
1586
|
-
{ field: 'state', value: '1' },
|
|
1587
|
-
{ field: 'approval', value: 'approved' },
|
|
1588
|
-
{ field: 'business_justification', value: 'New employee onboarding equipment provisioning' },
|
|
1589
|
-
{ field: 'requested_by', value: '{{trigger.current.manager}}' },
|
|
1590
|
-
{ field: 'opened_by', value: 'system' },
|
|
1591
|
-
{ field: 'due_date', value: '{{trigger.current.start_date}}' }
|
|
1592
|
-
]
|
|
1593
|
-
},
|
|
1594
|
-
outputs: {
|
|
1595
|
-
equipment_request_id: 'string',
|
|
1596
|
-
request_number: 'string',
|
|
1597
|
-
estimated_delivery: 'string'
|
|
1598
|
-
},
|
|
1599
|
-
exit_conditions: { success: true }
|
|
1600
|
-
},
|
|
1601
|
-
{
|
|
1602
|
-
name: 'Send Comprehensive Welcome Notification',
|
|
1603
|
-
type: 'notification',
|
|
1604
|
-
order: 300,
|
|
1605
|
-
description: 'Multi-recipient welcome notification with complete onboarding information',
|
|
1606
|
-
inputs: {
|
|
1607
|
-
recipients: '{{trigger.current.email}}',
|
|
1608
|
-
cc: '{{trigger.current.manager.email}},hr-team@company.com',
|
|
1609
|
-
bcc: 'it-onboarding@company.com',
|
|
1610
|
-
subject: 'Welcome to {{sys.property.company_name}} - Your Onboarding Information',
|
|
1611
|
-
message: `Welcome to {{sys.property.company_name}}, {{trigger.current.first_name}}!
|
|
1612
|
-
|
|
1613
|
-
We're excited to have you join our team. Your onboarding process has been initiated automatically.
|
|
1614
|
-
|
|
1615
|
-
== YOUR ACCOUNT INFORMATION ==
|
|
1616
|
-
Employee Number: {{comprehensive_user_account_setup.account_setup.employee_number}}
|
|
1617
|
-
Username: {{comprehensive_user_account_setup.account_setup.username}}
|
|
1618
|
-
Email: {{comprehensive_user_account_setup.account_setup.email}}
|
|
1619
|
-
Start Date: {{trigger.current.start_date}}
|
|
1620
|
-
|
|
1621
|
-
== ACCOUNT ACCESS ==
|
|
1622
|
-
Your account has been provisioned with the following roles:
|
|
1623
|
-
{{#each comprehensive_user_account_setup.role_assignments}}
|
|
1624
|
-
• {{this}}
|
|
1625
|
-
{{/each}}
|
|
1626
|
-
|
|
1627
|
-
System access requests have been submitted for:
|
|
1628
|
-
{{#each comprehensive_user_account_setup.access_requests}}
|
|
1629
|
-
• {{this.system}} (Request: {{this.request_id}})
|
|
1630
|
-
{{/each}}
|
|
1631
|
-
|
|
1632
|
-
== EQUIPMENT & WORKSPACE ==
|
|
1633
|
-
Equipment Request: {{equipment_workspace_provisioning.request_number}}
|
|
1634
|
-
Estimated Delivery: {{equipment_workspace_provisioning.estimated_delivery}}
|
|
1635
|
-
Workspace Location: {{trigger.current.location.name}}
|
|
1636
|
-
|
|
1637
|
-
Your equipment package will be delivered by your start date and includes:
|
|
1638
|
-
• Laptop with standard software configuration
|
|
1639
|
-
• Monitor and accessories
|
|
1640
|
-
• Mobile device and accessories
|
|
1641
|
-
• Security badge and building access
|
|
1642
|
-
• Office supplies starter kit
|
|
1643
|
-
|
|
1644
|
-
== FIRST DAY CHECKLIST ==
|
|
1645
|
-
□ Arrive at reception by 9:00 AM
|
|
1646
|
-
□ Collect your security badge and equipment
|
|
1647
|
-
□ Meet with your manager: {{trigger.current.manager.name}}
|
|
1648
|
-
□ Complete required training modules
|
|
1649
|
-
□ Attend new employee orientation
|
|
1650
|
-
□ Set up your workspace
|
|
1651
|
-
□ Schedule one-on-one meetings with team members
|
|
1652
|
-
|
|
1653
|
-
== IMPORTANT CONTACTS ==
|
|
1654
|
-
Direct Manager: {{trigger.current.manager.name}} ({{trigger.current.manager.email}})
|
|
1655
|
-
HR Representative: {{trigger.current.hr_contact.name}} ({{trigger.current.hr_contact.email}})
|
|
1656
|
-
IT Support: {{sys.property.it_service_desk_email}} | {{sys.property.it_service_desk_phone}}
|
|
1657
|
-
Facilities: {{sys.property.facilities_email}}
|
|
1658
|
-
|
|
1659
|
-
== RESOURCES ==
|
|
1660
|
-
Employee Handbook: {{sys.property.employee_handbook_url}}
|
|
1661
|
-
IT Support Portal: {{sys.property.it_portal_url}}
|
|
1662
|
-
Company Directory: {{sys.property.directory_url}}
|
|
1663
|
-
Benefits Information: {{sys.property.benefits_url}}
|
|
1664
|
-
|
|
1665
|
-
== TRAINING SCHEDULE ==
|
|
1666
|
-
Your manager will provide your specific training schedule, but expect to complete:
|
|
1667
|
-
• Company orientation (Day 1)
|
|
1668
|
-
• Department-specific training (Week 1)
|
|
1669
|
-
• System training sessions (Week 1-2)
|
|
1670
|
-
• Safety and compliance training (Week 2)
|
|
1671
|
-
|
|
1672
|
-
If you have any questions before your start date, please don't hesitate to reach out to your manager or HR team.
|
|
1673
|
-
|
|
1674
|
-
Welcome aboard!
|
|
1675
|
-
|
|
1676
|
-
{{sys.property.company_name}} People Team
|
|
1677
|
-
|
|
1678
|
-
---
|
|
1679
|
-
This message was generated automatically as part of your onboarding process.
|
|
1680
|
-
Onboarding ID: {{trigger.current.sys_id}}`,
|
|
1681
|
-
notification_type: 'welcome',
|
|
1682
|
-
priority: 'normal',
|
|
1683
|
-
tracking_enabled: true
|
|
1684
|
-
},
|
|
1685
|
-
outputs: {
|
|
1686
|
-
sent: 'boolean',
|
|
1687
|
-
welcome_confirmed: 'boolean',
|
|
1688
|
-
notification_id: 'string',
|
|
1689
|
-
recipients_notified: 'number'
|
|
1690
|
-
},
|
|
1691
|
-
exit_conditions: { success: true }
|
|
1692
|
-
}
|
|
1693
|
-
]
|
|
1694
|
-
};
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
exports.ServiceNowXMLFlowMCP = ServiceNowXMLFlowMCP;
|
|
1698
|
-
// Start the server
|
|
1699
|
-
const server = new ServiceNowXMLFlowMCP();
|
|
1700
|
-
server.start().catch(error => {
|
|
1701
|
-
console.error('Failed to start XML Flow MCP server:', error);
|
|
1702
|
-
process.exit(1);
|
|
1703
|
-
});
|
|
1704
|
-
//# sourceMappingURL=servicenow-xml-flow-mcp.js.map
|