- 0 minutes to read

Generate O2C Demo Data - PowerShell Script

Automate realistic Order-to-Cash demo data generation with 7 integration steps, multi-format support, and BPM metadata. This PowerShell script generates complete order flows for testing, visualization, and integration landscape demonstration.

  • ✅ Generate 7-step O2C flows (Steps 0-6) with 90% probabilistic progression
  • ✅ Multi-format messages (JSON, XML, CSV, PSV) across different systems
  • ✅ BPM metadata included for integration landscape visualization
  • ✅ 100 orders generating ~653 Log Events in < 2 seconds

Quick Facts

  • Location: Generate-O2C-Demo-Data.ps1 (Demo folder)
  • Default: 100 orders, base time 06:00 UTC, output to file or Log API
  • Data: Each order generates 14 events minimum (2 per step), completes in 90-120 minutes simulation time
  • First Order: Always completes all 7 steps for guaranteed demo content

Use Cases and Execution

Use Case 1: Quick Preview (Dry Run)

Scenario: Test the script locally and review generated structure before full execution.

.\Generate-O2C-Demo-Data.ps1 -DryRun

Output: Generates first order only. Result: ~14 events in memory, displayed as preview.


Use Case 2: Export Demo Dataset to File

Scenario: Generate complete dataset and export to JSON file for testing/documentation.

.\Generate-O2C-Demo-Data.ps1 -OrderCount 100 -ExportToFile -OutputFile "C:\Temp\O2C-Demo.json"

Output: JSON file with ~653 events (~200-300 KB). Use: Import into Postman, integrate with logging systems, or analyze BPM flows.


Use Case 3: Small Batch (Development/Testing)

Scenario: Generate fewer orders for rapid testing cycles.

.\Generate-O2C-Demo-Data.ps1 -OrderCount 10 -ExportToFile -OutputFile "C:\Temp\O2C-10.json"

Output: 10 orders (~65 events, ~50-70 KB). Use: Quick validation, local testing, CI/CD pipeline smoke tests.


Use Case 4: Large Batch (Production Demo)

Scenario: Generate comprehensive dataset for BPM visualization and integration landscape demo.

.\Generate-O2C-Demo-Data.ps1 -OrderCount 500 -ExportToFile -OutputFile "C:\Temp\O2C-500.json"

Output: 500 orders (~3,265 events, ~1-1.5 MB). Use: Demonstrate integration scale, BPM visualization, landscape topology.


Use Case 5: Direct API Integration (Production)

Scenario: Send events directly to Nodinite Log API endpoint.

.\Generate-O2C-Demo-Data.ps1 `
  -LogApiUrl "https://your-nodinite-instance/api/v2/LogEvents" `
  -ApiKey "your-api-key-here" `
  -OrderCount 100

Output: Events sent directly to Log API. Use: Live BPM visualization, real-time integration landscape updates, production demonstrations.


Parameters

Parameter Type Default Description
LogApiUrl string https://localhost:5001/api/v2/LogEvents 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 export
OrderCount int 100 Number of orders to generate
ExportToFile switch $false Export to JSON file instead of calling API
DryRun switch $false Preview mode (first order only)

Key Features

7-Step O2C Process: Steps 0-6 with 90% progression probability per step. First order always completes all steps.

Multi-Format Support: JSON (Steps 0, 3, 6), XML (Steps 1, 4), CSV (Step 2), PSV (Step 5) - demonstrates format diversity.

Correlation ID Format: {PREFIX}-{YYYYMMDD}-{HHMM}-{SEQUENCE} (e.g., PIC-20251024-0930-0001) for end-to-end traceability.

BPM Metadata: Each event includes RepositoryBinding with Service, ExternalServiceRelations, InternalServiceRelations, and BPM topology data.

Realistic Timing: Base time 06:00 UTC, 0.5-5 minute increments per step, 2-10 minute order spacing, processing times 5-300ms.

Output: ~653 events from 100 orders (~200-300 KB), ~65 events per order average, generated in < 2 seconds.

  • Step 5: 59 events (59% probability)
  • Step 6: 53 events (53% probability)

Average Events per Order: 6.53 Full Happy-Path Orders: ~53 (53%) Incomplete Orders: ~47 (47%) First Order: Always completes all 7 steps (100% complete for testing)

Data Volume

  • File Size (JSON): ~200-300 KB
  • Generation Time: < 2 seconds
  • Each Log Event: ~1-2 KB
  • Each RepositoryBinding: ~3-5 KB (includes BPM metadata)

Output Examples

Export Format

When exported to file with -ExportToFile, the output is a JSON array of log events. Each event includes the RepositoryBinding with BPM metadata:

[
  {
    "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-14T06:05:30.123Z",
    "ProcessName": "O2C-Order-Reception",
    "Context": {
      "FileName": "ORD-10001-order-received-from-customer.json",
      "OrderNumber": "ORD-10001",
      "CustomerId": "CUST-001",
      "CustomerName": "Acme Corporation",
      "OrderAmount": "99.95",
      "ExtendedProperties/1.0#RepositoryBinding": "{\"Name\":\"Standard Transport Contract\",\"Service\":{\"Name\":\"INT1337-RCV-Order-Incoming\",\"Direction\":\"Receive\",\"System\":{\"Name\":\"Portal\"},\"Integration\":{\"Name\":\"INT1337 - Order-to-Cash\"},\"BPMs\":[{\"Name\":\"INT1337 - Order-to-Cash Flow\",\"ArtifactRenaming\":\"Order Received\",\"Domain\":{\"Name\":\"Sales\",\"Index\":0},\"Step\":0,\"ServiceRelations\":[...]}]}}"
    },
    "Body": "eyJnZW5lcmF0ZWRBdCI6IjIwMjUtMTAtMTRUMDY6MDU6MzAuMDAwMDAwMFoiLCJjdXJyZW5jeSI6IlVTRCIsImJhdGNoSWQiOiJiYXRjaC0yMDI1LTEwLTE0LTAwMSIsIm9yZGVyRGF0ZSI6IjIwMjUtMTAtMTRUMDY6MDU6MzAuMDAwMDAwMFoiLCJvcmRlcklkIjoiT1JELTEwMDAxIiwib3JkZXJUb3RhbCI6OTkuOTUsIm9yZGVyUm93cyI6W3sicm93SWQiOjEsImxpbmVUb3RhbCI6OTkuOTUsInVuaXRQcmljZSI6OTkuOTUsInF1YW50aXR5IjoxLCJza3UiOiJTS1UtREVNTy0wMDEiLCJkZXNjcmlwdGlvbiI6IkRlbW8gV2lkZ2V0In1dLCJjdXN0b21lciI6eyJjdXN0b21lcklkIjoiQ1VTVC0wMDEiLCJuYW1lIjoiQWNtZSBDb3Jwb3JhdGlvbiIsImVtYWlsIjoib3JkZXJzQGFjbWUuZXhhbXBsZS5jb20ifX0="
  },
  ...
]

Note: The Body field contains the base64-encoded message (JSON/XML/CSV/PSV). The ExtendedProperties/1.0#RepositoryBinding in Context contains the integration metadata for visualization.


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 - first order only)
.\Generate-O2C-Demo-Data.ps1 -DryRun

# Option B: Export 100 orders to file
.\Generate-O2C-Demo-Data.ps1 -ExportToFile -OutputFile "C:\Temp\O2C-Demo.json"

# Option C: Export custom count to file
.\Generate-O2C-Demo-Data.ps1 -OrderCount 500 -ExportToFile -OutputFile "C:\Temp\O2C-500.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

  1. Export data: .\Generate-O2C-Demo-Data.ps1 -ExportToFile
  2. Use Postman Collection to batch import the JSON
  3. 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 (50 orders): < 1 second
  • Medium batch (100 orders): < 2 seconds
  • Large batch (500 orders): ~5 seconds
  • Very large batch (1000 orders): ~10 seconds

Memory Usage

  • Approximately 20-50 MB RAM for 100 orders
  • Approximately 100-200 MB RAM for 1000 orders
  • JSON serialization uses efficient approach

Network Considerations

If sending to Log API:

  • Each event: ~1-2 KB (plus ~3-5 KB RepositoryBinding in Context)
  • Total for 100 orders: 100 orders × 6.5 events × 4 KB avg = ~2.6 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

  1. Run the script to generate demo data
  2. Examine sample events to understand structure
  3. Import to Nodinite using Log API or batch tool
  4. Visualize in Nodinite UI to see BPM and Integration landscape
  5. Create Search Fields based on Order context and message types

Next Steps

  • Run the script with -DryRun to preview first order structure
  • Export demo data with -ExportToFile to JSON
  • Import to Nodinite Log API for complete testing