You are here: Business Rules > Business Actions > Execute JavaScript > Event Binds

Event Binds

Business Actions and Business Conditions can use any of the event binds to access the selected event object.

Bind Name

Description

Current Event Batch

This bind is only available in actions used as an OIEP Preprocessor and gives access to the batch of events currently being handled. This makes it possible to examine the events in the batch and to add new objects to the batch.

In this example, Current Event Batch is bound to the variable 'currentEventBatch'. For each event in the batch, the code accessed the object (node) for which the event was generated, checks if it is a product, and if so, adds the parent object to the batch.

eventsList = currentEventBatch.getEvents();
for (var i = 0; i < eventsList.size(); i++) {
var node = eventsList.get(i).getNode();
if (node instanceof com.stibo.core.domain.Product) {
currentEventBatch.addAdditionalNode(node.getParent());
}
}

Current Event Queue

Bind available for conditions and actions used as OIEP event filters / event generators. This bind gives access to the event queue tied to the OIEP and from an action makes it possible to, for example, add derived events to the queue.

In this example, Current Event Queue is bound to 'currentEventQueue', Current Object is bound to the variable 'currentObject', and a derived event is bound to the variable 'myEvent' via the Event Type bind. The code queues an event for the parent of current object if current object is a product.

if (currentObject instanceof com.stibo.core.domain.Product) {
currentEventQueue.queueDerivedEvent(myEvent, currentObject.getParent());
}

Current Event Type

Binds the current event type and can be hooked into an endpoint as filters / generators to examine the current event. This bind is available for conditions and actions used as OIEP event filters / event generators. Use this to examine the type of the current event.

In this example, Current Event Type is bound to 'currentEventType' and the code checks whether the current event is a core 'modify' event.

if (currentEventType.equals(com.stibo.core.domain.eventqueue.BasicEventType.Modify)) {
// Do something if core modify event
}

Event Queue

Bind available from conditions and actions, although typically used in actions. Use the bind from an action to queue an event on any event queue in the system.

In this example, a derived event is bound to the variable 'myEvent' via the Event Type bind, an event queue is bound to the variable 'someEventQueue' via the Event Queue bind, and Current Object is bound to 'currentObject'. The example places a 'myEvent' event on the queue for current object.

someEventQueue.queueDerivedEvent(myEvent, currentObject);

Event Type

Bind available for actions and conditions, although typically used in actions, binds a derived event to a JavaScript variable.

In this example, a derived event is bound to the variable 'myEvent' via the Event Type bind, an event queue is bound to the variable 'someEventQueue' via the Event Queue bind and Current Object is bound to 'currentObject'. The example places a 'myEvent' event on the queue for current object.

someEventQueue.queueDerivedEvent(myEvent, currentObject);

The example code below expects these bindings:

Checking Current Event

From actions and conditions used as filters / generators in an outbound integration endpoint, you can obtain the current event using a binding as shown above. The event will be either a core STEP event (BasicEventType Enum) or a derived event (DerivedEventType interface).

This code checks whether current event is a Core event:

if (currentEvent instanceof com.stibo.core.domain.eventqueue.BasicEventType) {
// It is a core event
}

This code checks whether current event is a code Modify event:

if (currentEvent.equals(com.stibo.core.domain.eventqueue.BasicEventType.Modify)) {
// It is a core Modify event
}

This code checks whether current event is a Derived event:

if (currentEvent instanceof com.stibo.core.domain.eventqueue.DerivedEventType) {
// It is a derived event
}

This code checks whether current event is derived 'WebModify' event:

if (currentEvent.equals(webModify)) {
// It is a derived WebModify event
}

Queuing a Derived Event

From an action, you can queue derived events using the following method on the EventQueue interface:

queueDerivedEvent(DerivedEventType event, Node node) 

For a generator action hooked into an outbound integration endpoint, you can queue a derived event on current event queue as follows (using bindings described above):

currentEventQueue.queueDerivedEvent(webModify, node);

From any action, you can queue a derived event on an event queue via the 'Event Queue' and 'Event Type' bindings:

oiep2.queueDerivedEvent(webModify, node);

2017, Stibo Systems