Skip to content

Emit Events (bizzStream.emitEvent)

To trigger an event within the BizzStream event framework, you can employ the bizzStream.emitEvent method.

Syntax

bizzStream.emitEvent(type, info, options)

Parameters

Parameter Type Required Description
type String Yes The type of the event.
info Object Yes The information of the event.
options Object No Additional options (see below).

Options

Option Type Default Description
delayInTransaction Boolean false When true and the script runs inside a transactional action, the event is queued and emitted only after the transaction has been committed successfully. This prevents downstream listeners from acting on data that may still be rolled back. Has no effect outside of a transactional context.

Return Value

None.

Example

The following example shows how to trigger a PURCHASE_ORDER_CREATED event using the bizzStream.emitEvent method:

bizzStream.emitEvent("PURCHASE_ORDER_CREATED", {code: serverDocument.code});

Example with Delayed Emission in a Transactional Action

When the script runs inside a transactional action, pass { delayInTransaction: true } to ensure the event is only emitted after the transaction commits:

bizzStream.emitEvent(
    "PURCHASE_ORDER_CREATED",
    { code: serverDocument.code },
    { delayInTransaction: true }
);