The incident events business rule comes with the system and defines a number of events that can be triggered by different actions in the Incident table.

Figure 1. Incident events business rule
Incident events business rule snippet

This business rule defines several events, three of which are triggered after a record in the Incident table is inserted or updated. The first script is:

if (current.operation() != 'insert' && current.comments.changes()) {
gs.eventQueue("incident.commented", current, gs.getUserID(), gs.getUserName());
}

The condition in this script requires that a change be made to the Comments field in an existing (not inserted) incident record. If this condition is true, then the platform adds the incident.commented event to the event queue.

The second condition requires that a record be inserted before the event is added to the queue.

if (current.operation() =='insert') {

The third condition is true whenever the incident record is updated (including updates to the Comments field, as specified by the first script).

if (current.operation() == 'update')

The then part of each script, the gs.eventQueue function, adds the event to the event queue. This statement uses the following syntax, set off with braces:

gs.eventQueue("incident.updated", current, gs.getUserID(), gs.getUserName());
The gs.eventQueue function takes the following parameters:
Note: The gs.EventQueue function works directly with the backend and therefore business rules that are called by gs.EventQueue() are not invoked.