Skip to main content

Events

Event steps allow flows to publish business events that can trigger other processes through the publish-subscribe pattern.

Publish Event

Raises a business event that can trigger event handlers.

ParameterDescription
Event DefinitionThe event type to publish
Event Properties BindingMapping of values to event properties

When an event is published:

  1. An immutable event instance is created
  2. All synchronous handlers execute immediately (in order)
  3. Asynchronous handlers are queued for background execution
  4. The flow continues after synchronous handlers complete

Example - Simple Event:

PUBLISH EVENT
Event Definition: OrderPlaced
Event Properties Binding:
OrderId: Order.Id
CustomerId: Order.CustomerId
OrderNumber: Order.OrderNumber
TotalAmount: Order.TotalAmount
OrderDate: NOW()

Example - Event with Calculated Properties:

# First calculate some values
RUN LOGIC BLOCK
Logic Block: CalculateOrderMetrics
Inputs: Order
→ Outputs: IsHighValue, IsFirstOrder, CustomerLifetimeValue

# Then publish event with all data
PUBLISH EVENT
Event Definition: OrderCompleted
Event Properties Binding:
OrderId: Order.Id
CustomerId: Order.CustomerId
TotalAmount: Order.TotalAmount
IsHighValue: IsHighValue
IsFirstOrder: IsFirstOrder
CustomerLifetimeValue: CustomerLifetimeValue
CompletedDate: NOW()
ProcessedBy: CurrentUser.Id

Event Patterns

Workflow Completion Events

Publish events when significant workflow milestones are reached:

# At the end of an order processing flow

CONDITION: Order Fully Processed?
Condition: AllStepsSuccessful == true

TRUE BRANCH:
PUBLISH EVENT
Event Definition: OrderProcessingCompleted
Event Properties Binding:
OrderId: Order.Id
ProcessingDuration: DATEDIFF(StartTime, NOW())
ItemsProcessed: ProcessedCount
Status: "Success"

FALSE BRANCH:
PUBLISH EVENT
Event Definition: OrderProcessingFailed
Event Properties Binding:
OrderId: Order.Id
FailureReason: ErrorMessage
FailedAtStep: FailedStepName
Status: "Failed"

Entity Lifecycle Events

Publish events at key points in an entity's lifecycle:

# Customer Onboarding Flow

# After initial setup
PUBLISH EVENT
Event Definition: CustomerCreated
Event Properties Binding:
CustomerId: Customer.Id
CustomerName: Customer.Name
CreatedBy: CurrentUser.Id

# ... additional onboarding steps ...

# After onboarding complete
PUBLISH EVENT
Event Definition: CustomerOnboarded
Event Properties Binding:
CustomerId: Customer.Id
OnboardingDuration: DATEDIFF(Customer.CreatedOn, NOW())
AssignedAccountManager: Customer.AccountManagerId

Integration Events

Publish events when external system interactions complete:

# After payment processing
CALL REST API
Service Connection: PaymentGateway
Operation: ProcessPayment
→ PaymentResult

PUBLISH EVENT
Event Definition: PaymentProcessed
Event Properties Binding:
OrderId: Order.Id
PaymentAmount: Order.TotalAmount
TransactionId: PaymentResult.TransactionId
PaymentMethod: SelectedMethod
Success: PaymentResult.Status == "approved"
ProcessedAt: NOW()

Batch Processing Events

Publish events during and after batch operations:

# Batch processing flow
NEW VARIABLE: ProcessedCount = 0
NEW VARIABLE: ErrorCount = 0

ITERATOR: Process Records
Collection: RecordsToProcess
Item Variable: Record

Steps:
# Process each record...

# Publish progress event periodically
CONDITION: Should Report Progress?
Condition: ProcessedCount % 100 == 0

TRUE BRANCH:
PUBLISH EVENT
Event Definition: BatchProgressUpdate
Event Properties Binding:
BatchId: BatchJob.Id
ProcessedCount: ProcessedCount
TotalCount: TotalRecords
PercentComplete: (ProcessedCount / TotalRecords) * 100

# After batch completes
PUBLISH EVENT
Event Definition: BatchCompleted
Event Properties Binding:
BatchId: BatchJob.Id
TotalProcessed: ProcessedCount
ErrorCount: ErrorCount
Duration: DATEDIFF(BatchStartTime, NOW())

Best Practices

Publish at Business Moments: Events should represent meaningful business occurrences, not technical operations. "OrderPlaced" is better than "RecordSaved".

Include Sufficient Context: Event properties should contain enough information for handlers to do their work without additional queries.

Keep Events Focused: Each event should represent one thing that happened. Don't combine multiple events into one.

Consider Handler Execution: Remember that synchronous handlers block the publishing flow. Keep synchronous handlers fast and move heavy processing to asynchronous handlers.

Don't Rely on Handler Success: The publishing flow should not depend on what handlers do. Handlers may fail independently.

Avoid Circular Events: Be careful not to create event chains where handlers publish events that trigger the original flow.

Document Event Contracts: Clearly document when each event is published and what properties it provides so handler developers know what to expect.

Event Handlers

Events by themselves don't do anything - they need Event Handlers to respond to them. See Event documentation for details on creating Event Definitions and Event Handlers.