Skip to main content

Events

Events can be used as communication between components and are typically raised when something has occurred. You can read more about Events by reading our Introduction to Events guide.

Event Types

Event
{
organizationId: string,
id: string,
name: string,
attributes: Record<string, string>,
timestampUtc: datetime
}
CreateEventOptions
{
timestampUtc: datetime,
attributes: Record<string, string>
}
QueryEventOptions
{
names: string[],
startUtc: datetime,
endUtc: datetime,
attributes: Record<string, string>
}

createEvent

Read-only Mode

This function is not available in read-only mode.

Creates a new custom Event.

createEvent(name, options)

Parameters

NameTypeDescriptionOptional
namestringThe name of the Event.
optionsCreateEventOptionsOptions to create the Event with.

Returns The created Event.

Example

// Create an Event with attributes
var event = createEvent('status-changed', {
attributes: {
"source": "udf",
"status": 1
}
});

getEvent

Gets an Event by its identifier.

getEvent(eventId)

Parameters

NameTypeDescription
eventIdstringThe identifier of the Event.

Returns The Event with the specified identifier.

Example

var event = getEvent('c2012196-4349-408e-9dd1-8107b61fd8fb');

getEvents

Gets a collection of Events using optional query criteria.

getEvents(options)

Parameters

NameTypeDescription
optionsQueryEventOptionsOptions for querying Events.

Returns A collection of Events which meet the query criteria.

Example

// Query all 'status-changed' Events which a udf source.
var udfEvents = getEvents({
names: ['status-changed'],
attributes: {
source: 'udf'
}
});

// Query all 'status-changed' Events within the last week.
var date = new Date();
var timeFrameEvents = getEvents({
names: ['status-changed'],
startUtc: date - 7,
endUtc: date
});