PowerShell Script: Generate O2C Demo Data
Overview
The Generate-O2C-Demo-Data.ps1
PowerShell script automates the generation of 1000 realistic Order-to-Cash process interchanges. Each interchange follows a probabilistic happy-path scenario where:
- Every order starts at Step 1 (Order Received from Customer)
- Random step completion - Each order has a 90% probability of progressing to the next step
- Realistic data values - All orders share the same customer and product data for consistency
- Varying timestamps - Each step adds 0-5 minute increments for realistic processing times
- Happy-path assumption - Incomplete orders receive log status
-1337
on their final step
Script Location
c:\Code\Docs\products-documentation\Integration Manager\Documentation\Core Services\Log API\Troubleshooting\Demo\Generate-O2C-Demo-Data.ps1
Usage Examples
Generate and Export to File
Export all generated log events to a JSON file:
.\Generate-O2C-Demo-Data.ps1 -OutputFile "C:\Temp\O2C-Orders.json" -ExportToFile
Dry Run Preview (First 2 Orders)
Preview the structure without generating full dataset:
.\Generate-O2C-Demo-Data.ps1 -DryRun
Generate Smaller Dataset
Create 100 orders instead of 1000:
.\Generate-O2C-Demo-Data.ps1 -OrderCount 100 -ExportToFile -OutputFile "C:\Temp\O2C-100-Orders.json"
Production: Send to Nodinite Log API
Send events directly to your Nodinite instance (production):
.\Generate-O2C-Demo-Data.ps1 -LogApiUrl "https://your-nodinite-instance/api/v2/LogEvents" `
-ApiKey "your-api-key"
Parameters
Parameter | Type | Default | Description |
---|---|---|---|
LogApiUrl |
string | https://localhost:5001/api/v2/LogEvents |
URL to Nodinite Log API endpoint |
ApiKey |
string | YOUR_API_KEY_HERE |
API authentication key |
OutputFile |
string | C:\Temp\O2C-Demo-Data.json |
Output file path for -ExportToFile option |
OrderCount |
int | 1000 |
Number of orders to generate |
ExportToFile |
switch | $false |
Export to JSON file instead of calling API |
DryRun |
switch | $false |
Preview mode (generates first 2 orders only) |
Script Features
1. Realistic Order Flow
Each order progresses through these 7 steps with 90% probability of advancing:
# | Milestone | Probability | Cumulative |
---|---|---|---|
1 | Order Received | 100% | 100% |
2 | Order Entry | 90% | 90% |
3 | Confirmation | 81% | 81% |
4 | Order Planned | 73% | 73% |
5 | Completed | 66% | 66% |
6 | Delivered | 59% | 59% |
7 | Invoiced | 53% | 53% |
Example: ~530 orders will complete all 7 steps (happy path complete), while ~470 will stop at various intermediate steps.
Incremental Order IDs
Orders are numbered sequentially:
ORD-10001
throughORD-11000
Correlation IDs
Each order receives a correlation ID that becomes the ApplicationInterchangeId
for traceability:
- Format:
{PREFIX}-{DATEPART}-{SEQUENCE}
- Semantic breakdown:
{PREFIX}
: Customer code (e.g.,PIC
){DATEPART}
: Date when script executes inYYYYMMDD
format (e.g.,20251022
){SEQUENCE}
: Order sequence number within the batch (e.g.,0001
,0042
,1000
)
- Example:
PIC-20251022-0001
,PIC-20251022-0042
,PIC-20251022-1000
(if script runs on October 22, 2025) - Example:
PIC-20251023-0001
,PIC-20251023-0002
, etc. (if script runs on October 23, 2025) - All steps in an order share the same correlation ID (stored in
ApplicationInterchangeId
) - Important: The
{DATEPART}
is generated dynamically at script runtime based on the current system date, not hard-coded
DateTime Progression
- Base date: October 14, 2025 09:00:00 UTC
- Random increments: Each step adds 0-5 minutes
- Realistic delays:
- Steps 1-4 (Order Entry): ~7-23 minutes total
- Steps 5-6 (Logistics): ~2-5 days
- Step 7 (Invoicing): ~4.3 days
5. Multi-Format Message Support
Demonstrates format agnostic logging:
Step | Format | Content |
---|---|---|
1 | JSON | Customer order with line items |
2 | XML | ERP order entry confirmation |
3 | CSV | Order confirmation to customer |
4 | JSON | Production planning details |
5 | XML | Warehouse packing details |
6 | PSV | Proof of delivery |
7 | JSON | Invoice with payment terms |
6. Context Properties
Each log event includes rich context for business analytics:
"Context": {
"FileName": "ORD-10001-received",
"OrderNumber": "ORD-10001",
"CustomerId": "CUST-001",
"CustomerName": "Acme Corporation",
"OrderAmount": "99.95"
}
Note: The correlation ID is no longer stored in Context; instead it's now set on the ApplicationInterchangeId
field for proper end-to-end correlation tracking.
Additional step-specific context may be included (InvoiceId, TrackingNumber, etc.)
7. Log Status Handling
- Success (0): All completed steps receive log status
0
- Incomplete (-1337): The final step for incomplete orders receives status
-1337
- This demonstrates how to track order stops/failures in the pipeline
Generated Data Summary
Default Generation (1000 Orders)
Total Log Events: ~6,530 events
- ~100% complete step 1: ~1,000 events
- ~90% complete step 2: ~900 events
- ~81% complete step 3: ~810 events
- ~73% complete step 4: ~730 events
- ~66% complete step 5: ~660 events
- ~59% complete step 6: ~590 events
- ~53% complete step 7: ~530 events
Average Events per Order: 6.53
Full Happy-Path Orders: ~530 (53%)
Incomplete Orders: ~470 (47%)
Data Volume
- File Size (JSON): ~2-3 MB
- Generation Time: ~5-10 seconds
- Each Log Event: ~1-2 KB
Output Examples
Export Format
When exported to file with -ExportToFile
, the output is a JSON array of log events:
[
{
"LogAgentValueId": -5,
"EndPointName": "Portal-OrderReceived-Drop",
"EndPointUri": "C:\\Integration\\Portal\\Orders\\In",
"EndPointDirection": 0,
"EndPointTypeId": 60,
"OriginalMessageTypeName": "O2C.Order.Received/1.0",
"LogDateTime": "2025-10-14T09:05:30.123Z",
...
},
...
]
Execution Steps
Step 1: Open PowerShell as Administrator
# Open Windows Terminal or PowerShell ISE
Step 2: Navigate to Demo Directory
cd "c:\Code\Docs\products-documentation\Integration Manager\Documentation\Core Services\Log API\Troubleshooting\Demo"
Step 3: Set Execution Policy (if needed)
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
Step 4: Run the Script
# Option A: Preview (dry run)
.\Generate-O2C-Demo-Data.ps1 -DryRun
# Option B: Export to file
.\Generate-O2C-Demo-Data.ps1 -ExportToFile -OutputFile "C:\Temp\O2C-Demo.json"
Step 5: View Results
# Inspect the generated file
Get-Content "C:\Temp\O2C-Demo.json" | ConvertFrom-Json | Measure-Object
Get-Item "C:\Temp\O2C-Demo.json" | Select-Object Length
Integration with Nodinite
Using Generated Data in Log API
Option 1: Import JSON File to Postman
- Export data:
.\Generate-O2C-Demo-Data.ps1 -ExportToFile
- Use Postman Collection to batch import the JSON
- Or parse JSON and call Log API in a loop
Option 2: Direct API Call (Future Enhancement)
The script includes framework for direct API calls. To implement:
# Add to script after log event creation:
$headers = @{
"Content-Type" = "application/json"
"x-ms-client-tracking-id" = $correlationId
"Authorization" = "Bearer $ApiKey"
}
$response = Invoke-RestMethod -Uri $LogApiUrl `
-Method Post `
-Headers $headers `
-Body ($logEvent | ConvertTo-Json)
Performance Considerations
Generation Performance
- Small batch (100 orders): < 2 seconds
- Medium batch (500 orders): ~5 seconds
- Large batch (1000 orders): ~10 seconds
Memory Usage
- Approximately 50-100 MB RAM for 1000 orders
- JSON serialization uses streaming-capable approach
Network Considerations
If sending to Log API:
- Each event: ~1-2 KB
- Total: 1000 orders × 6.5 events × 1.5 KB = ~10 MB
- Recommend batching: 50-100 events per API call
Troubleshooting
Issue: "Cannot find path"
Solution: Ensure PowerShell working directory is correct:
Get-Location
cd "c:\Code\Docs\products-documentation\Integration Manager\Documentation\Core Services\Log API\Troubleshooting\Demo"
Issue: Execution Policy Error
Solution: Set execution policy for current process:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
Issue: JSON Parse Error
Solution: Validate generated file is valid JSON:
$json = Get-Content "C:\Temp\O2C-Demo.json" | ConvertFrom-Json
$json | Measure-Object # Should show count of events
Next Steps
- Run the script to generate demo data
- Examine sample events to understand structure
- Import to Nodinite using Log API or batch tool
- Visualize in Nodinite UI to see BPM and Integration landscape
- Create Search Fields based on Order context and message types
Related Documentation
- Overview - O2C Demo overview and scenario
- 1. Order Received - Step 1 message sample
- 2. Order Entry - Step 2 message sample
- 3. Order Confirmation - Step 3 message sample
- 4. Order Planned - Step 4 message sample
- 5. Order Ready - Step 5 message sample
- 6. Order Shipped - Step 6 message sample
- 7. Order Invoiced - Step 7 message sample
- JSON Log Events
- Context Options
- Log API