Event: Get Node

The Event: Get Node allows a workflow to retrieve one or more Events from the current application and add them to the current workflow payload.

Get Event Node

Node Properties

The configuration for the Event: Get Node requires a query method and parameters to find a device connected to WEGnology.

Retrieval Mode

The first step is selecting a retrieval mode method to use to find an event or group of Events. The Event: Get Node has three different options:

  • One Event By ID: You can input a specific event’s ID to retrieve it or use a value on the payload. The ID can be hardcoded in the workflow editor or derived from a property on the current payload.
  • One Event By Query: You can create an advanced query to retrieve a single event. This query is templatable, and so part or all of the query can come from the current payload.
  • Multiple Events By Query: You can create an advanced query to retrieve multiple Events. This query is templatable, and so part or all of the query can come from the current payload.

Sort Field and Direction

When retrieving one or multiple Events by query, you can set the Sort Field and Sort Direction.

In the case of retrieving a single event, this controls what event will be returned when multiple Events match the query. In the case of retrieving multiple Events, this controls the order of the Events returned.

By default this will sort by creation date, descending (which means in the single event case, it will return the most recently created event matching the given query).

Page Number and Results Per Page

When retrieving multiple Events by query, you can set the Page Number and Results Per Page. Both are templatable fields.

Results Per Page: defines the (maximum) number of Events to return with this query. The maximum value is 1000, and the default is 100.

Page Number: defines the number of results to skip by multiplying this number by the Results Per Page field, allowing you to paginate through large numbers of Events.

Metadata

You will also have the option to return metadata in addition to the queried events.

  • Return just an array of results - The Event: Get Node’s result will be an array of events.
  • Return an object containing metadata along with results - The Event: Get Node’s result will be an object with keys for metadata properties in addition to an array of events in the items key.

An example of the Event: Get Node’s metadata can be found in the Node Example.

Result Path

It is required you specify where on the payload path you want the event or group of Events to be placed.

If you are querying for a single event, the event will be placed at that path (or null if the event is not found). If you are querying for multiple Events, the result will be an array of Events (potentially an empty array if no Events were found).

If the node errors, an object will be placed at this path with the an error property with details about the error

Node Example

For example, if we are querying for a single event to place on the path working.eventResult, the result will look like the following:

{
  "working": {
    "eventResult": {
      "sourceName": "hello@example.com",
      "state": "new",
      "level": "critical",
      "id": "5d30a508fd2aa0b015acbc99",
      "eventId": "5d30a508fd2aa0b015acbc99",
      "updates": [
        {
          "sourceName": "goodbye@example.com",
          "comment": "hi",
          "sourceId": "5d30a516fd2aa0b015acbc9b",
          "sourceType": "user",
          "creationDate": "2019-07-17T18:09:34.014Z"
        }
      ],
      "message": "",
      "lastUpdated": "2019-07-17T18:09:34.015Z",
      "creationDate": "2019-07-17T18:09:30.251Z",
      "applicationId": "5d30a50dfd2aa0b015acbc9a",
      "sourceId": "5d30a502fd2aa0b015acbc98",
      "sourceType": "user",
      "eventTags": {
        "location": "level1"
      },
      "subject": "hello"
    }
    ...
  },
  ...
}

If querying for multiple events with metadata, the result will look like the following:

{
  "working": {
    "eventResult": {
      "count": 100, //the number of events returned
      "query": { ... }, // the query used to find events
      "findMethod": "query",
      "perPage": 100,
      "page": 0,
      "totalCount": 193, //the number of events matched by the query
      "sortField": "creationDate",
      "sortDirection": "desc",
      "items": [ ... ] //The resulting events from the query
    }
  },
  ...
}

Node Errors

Given a response path of working.eventResult, a failed event query might look like:

{
  "working": {
    "eventResult": {
      "error": {
        "message": "hello is not a valid value for state",
        "type": "Validation"
      }
    },
    ...
  },
  ...
}

There are most common error that wil occur with this node are all around query validation. It is very easy to create an invalid query when using string templating.

For example, the above error would be returned if you tried to query for all Events with a state of hello (which is not a valid value for event state).

Was this page helpful?


Still looking for help? You can also search the WEGnology Forums or submit your question there.