User defined events in the SAP WebIDE template-IoT Freestyle App
SAP Leonardo IoT offers two WebIDE templates for rapid custom IoT application development: the “IoT Application template” and “Freestyle IoT Application Template”. In these templates there exist an event lists and for Maps on the ThingCards an Event Aggregation that are linked to the IoT Standard Events.
The Standard Events are limited in the ability to customize their usage; therefore, SAP Leonardo IoT also offers User-defined Events. User-defined Events enable to add EventPropertySets with freely configurable property fields to the Event (see here). You can configure several different User-defined EventTypes to fit different application scenarios.
Accordingly, you might want to link the IoT EventList and Event Aggregation in the IoT Map’s ThingCard to a User-defined EventType. In this blog we explain you, how you can achieve this based on an existing Freestyle IoT Application. In the following you see a step-by-step guide who the application generated through IoT Web IDE template needs an adoption to work with User-defined events:
Event list with User Defined events:
- First replace the standard event type to user defined event type highlighted below in your manifest
- Open the event list control in the layout editor and change the column name and its binding to the right fields.
- Adopt advance list service (main service) in the manifest to load the metadata of User defined event
- Run the application, the ThingList will not show the things now
- Find the call of AdvanceThingList $metatdata in the browser developer tool network tab
- Copy the response of the $metadata.
- Go back to WebIDE and replace the content of metadata.xml located within your project structure inside the folder local services with the copied $metadata response
- Open Thing List and adjust the binding and expand parameters with user defined events, shown in the images below.
Map with User defined event:
- Follow the step1 of Thing list user defined event to adopt the advance list service $metadata with user defined events.
- Adjust the map bindings and expand parameters shown in the step3 of thing list below.
- Now bind the map status element with the desired User defined event statuses.
Now you should be able to see your User-defined events in the EventList, ThingList and ioT Maps. In the thing list it is always shows the aggregated data for the events based on the severity.