ApplicationExperience

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 Losant.

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 retriving one or multiple Events by query, you can set the Sort Field and Sort Direction.

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

By default this will sort by creation date, decending (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 retriving multiple Events by query, you can set the Page Number and Results Per Page. Both are tempaltable 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.

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 singe event, to place on the path data.myEvent, the result will look like the following:

{
  "data": {
    "myEvent": {
      "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"
    }
    ...
  },
  ...
}

Node Errors

Given a response path of data.myEvent, a failed event query might look like:

{
  "data": {
    "myEvent": {
      "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).