- 10 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 as Nodinite Log Events for testing, visualization, and integration landscape demonstrations.

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

Understanding the Data Generator

graph LR Script["fa:fa-terminal Generate-O2C-Demo-Data.ps1"] -->|"-DryRun"| Console["fa:fa-display Console preview"] Script -->|"-ExportToFile"| File["fa:fa-file-code JSON file"] File --> LogAPI["fa:fa-cloud-arrow-down Log API"] LogAPI --> Repo["fa:fa-sitemap Repository Model and BPM"] style Script fill:#9E59BB style Console fill:#2678BD style File fill:#2678BD style LogAPI fill:#3F827B style Repo fill:#93d16d

The script (purple) previews or exports the Log Events (blue); posted to the Log API (teal), they build the Repository Model and the BPM (green).

Quick Facts

  • Script: Copy the source from Generate O2C Demo Data Script and save it as Generate-O2C-Demo-Data.ps1
  • Default: 100 orders, base time 06:00 UTC, output to file or Log API
  • Data: Each order generates up to 14 events (2 per step, SequenceNo 1-14) and spans about 4-36 minutes of simulated time (30-300 seconds per step)
  • First Order: Always completes all 7 steps for guaranteed demo content; every other order completes at least 2 steps. It is always CUST-001 with one Demo Widget (USD 99.95), the order the step pages show
  • Business data: The other orders rotate through six customers and pick a product and a quantity, so the payloads differ; see Customers, products, and grouping
  • Log Agent: The script logs as Log Agent 5 ($LOG_AGENT_VALUE_ID), with Endpoint Type 60

Note

5 is also the default Log Agent for Azure Logic Apps logging. In an environment that already logs Logic Apps, or that other demos share, change $LOG_AGENT_VALUE_ID in your copy of the script to an id no other Log Agent uses, so the demo events stay separate.

Parameters

Parameter Type Default Description
LogApiUrl string https://localhost:40002/LogAPI/api/LogEvent Nodinite Log API endpoint; in v7 the endpoint is https://{host}:{port}/LogAPI/api/LogEvent (Log using REST). Not used yet: see the note below
ApiKey string YOUR_API_KEY_HERE API authentication key. Not used yet
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 a JSON file instead of calling the API
DryRun switch $false Preview mode (first order only)

Note

The script doesn't call the Log API. Without -ExportToFile it prints Would call Log API at … and the event count, and stops. Write the events to a file with -ExportToFile, then post them, for example with the call in Option 2.

Customers, products, and grouping

Order n gets customer number ((n - 1) mod 6) + 1, so every run of six orders or more has all six customers. All names are fictitious.

Customer Name City ZIP Country Warehouse Carrier
CUST-001 Contoso Corporation Springfield, IL 62701 US WH-01 Standard Courier
CUST-002 Fabrikam Inc. Springfield, IL 62704 US WH-01 Standard Courier
CUST-003 Northwind Traders Seattle, WA 98101 US WH-02 Pacific Express
CUST-004 Adventure Works Seattle, WA 98109 US WH-02 Pacific Express
CUST-005 Tailspin Toys Stockholm 111 51 SE WH-03 Nordic Freight
CUST-006 Wide World Importers Gothenburg 411 36 SE WH-03 Nordic Freight

Each order has one order line: SKU-DEMO-001 Demo Widget (USD 99.95), SKU-DEMO-002 Demo Gadget (USD 249.00), or SKU-DEMO-003 Demo Sprocket (USD 12.50), with a quantity of 1 to 5. The total follows, and an order of USD 500 or more gets the planning priority HIGH instead of NORMAL. The customer, ship-to address, warehouse, carrier, product, quantity, and total appear in the payloads of every step, and the CustomerId, CustomerName, and OrderAmount Context Properties follow the order. The flow, the Services, and the Log Statuses are the same for every order.

Group the orders by place and customer

The Order Received body carries a shipTo object, so a Log View can group the orders on up to four fields:

  1. Create Search Fields on O2C.Order.Received/1.0 with JSON Path expressions: $.shipTo.country, $.shipTo.city, $.shipTo.zip, and $.customer.name. Turn on suppress warnings, because older events have no shipTo, and reindex.
  2. Create a Log View with Data to search limited to that Message Type, and on the Grouping tab group by Country, City, ZIP, and Customer Name.
  3. Search today's run. Each group is one combination of the four values, shown together in the group header, such as US · Springfield · 62701 · Contoso Corporation: six groups for the six customers. The groups don't nest; see Group on several fields for a walkthrough.

Use Cases and Execution

Use Case 1: Quick Preview (Dry Run)

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

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

Output: Generates all orders, then prints the first 14 Log Events, which is the first order (it always completes all 7 steps). Result: 14 events displayed as a preview; nothing is exported or sent.

Use Case 2: Export Demo Dataset to File

Scenario: Generate the complete dataset and export it to a JSON file for testing or documentation.

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

Output: JSON file with ~1,090 events. 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 (~100 events). Use: Quick validation, local testing, CI/CD pipeline smoke tests.

Use Case 4: Large Batch (Production Demo)

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

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

Output: 500 orders (~5,300 events). Use: Demonstrate integration scale, BPM visualization, and landscape topology.

Use Case 5: Direct API Integration

Scenario: Send events directly to the Nodinite Log API endpoint.

.\Generate-O2C-Demo-Data.ps1 `
  -LogApiUrl "https://nodinite.contoso.com:40002/LogAPI/api/LogEvent" `
  -ApiKey "your-api-key-here" `
  -OrderCount 100

Output: The current script prints the target URL and the event count instead of posting the events; add the call shown in Option 2 below. Use: Live BPM visualization, real-time integration landscape updates, demonstrations.

Key Features

  • 7-Step O2C Process: Steps 0-6 with 90% progression probability per step. The 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 a Repository Binding with Service, ExternalServiceRelations, InternalServiceRelations, and BPM topology data.
  • Realistic Timing: Base time 06:00 UTC on the day you run the script, 0.5-5 minute increments per step, 1-5 seconds between a step's Receive and Send events, 2-10 minute order spacing, processing times 5-50 ms (Receive) and 40-300 ms (Send).
  • Error Marking: The last Send event of an incomplete order gets Log Status -1337; all other events get 0.

Expected Output

  • Log Events: ~1,090 events from 100 orders (about 10.9 per order on average), generated in < 2 seconds
  • Full Happy-Path Orders: ~57 (57%)
  • Incomplete Orders: ~47 (47%)
  • First Order: Always completes all 7 steps (100% complete for testing)

Data Volume

  • Each Log Event: ~1-2 KB
  • Each Repository Binding: ~3-5 KB (includes BPM metadata)

Output Examples

Export Format

When you export to file with -ExportToFile, the output is a JSON array of Log Events. Each event includes the Repository Binding 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:02:15.0000000Z",
    "EventDirection": 17,
    "SequenceNo": 1,
    "EventNumber": 1,
    "LogText": "Order Received from Customer",
    "ApplicationInterchangeId": "PIC-20251014-0915-0001",
    "LogStatus": 0,
    "ProcessName": "O2C-Order-Reception",
    "Context": {
      "FileName": "ORD-10001-order-received-from-customer.json",
      "OrderNumber": "ORD-10001",
      "CustomerId": "CUST-001",
      "CustomerName": "Contoso 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": "eyJiYXRjaElkIjoiYmF0Y2gtMjAyNS0x..."
  },
  ...
]

Note: The Body field contains the base64-encoded message (JSON/XML/CSV/PSV), shortened here. The ExtendedProperties/1.0#RepositoryBinding in the Context Options 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

Go to the folder where you saved the script:

cd "c:\Code\Docs\products-documentation\Integration Manager\Documentation\Repository Model\BPMs\Examples\Order-to-Cash"

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 a Postman Collection to batch import the JSON
  3. Or parse the JSON and call the Log API in a loop

Option 2: Direct API Call (Future Enhancement)

The script includes a framework for direct API calls. To implement it:

# 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)

See Log using REST for the v7 Log API endpoint and authentication options.

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 an efficient approach

Network Considerations

If you send to the Log API:

  • Each event: ~1-2 KB (plus ~3-5 KB Repository Binding in the Context)
  • Total for 100 orders: ~1,090 events × ~4 KB average = ~4 MB
  • Recommended batching: 50-100 events per API call

Troubleshooting

Issue: "Cannot find path"

Solution: Make sure the PowerShell working directory is the folder with the script:

Get-Location
cd "c:\Code\Docs\products-documentation\Integration Manager\Documentation\Repository Model\BPMs\Examples\Order-to-Cash"

Issue: Execution Policy Error

Solution: Set the execution policy for the current process:

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

Issue: JSON Parse Error

Solution: Validate that the 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