Events
- Timers and Schedulers both come with a specific Event inherited from the Thing Template:
- Both have a Data Shape allowing to capture the timestamp of when the Event was actually fired.
- Events in ThingWorx are triggered when a specific condition is met. In this context the condition is met and the Event is fired when a Timer has expired or a Scheduler's time is reached.
- Once an Event is triggered, Subscriptions will take care of executing custom Services to react to the Event.
Subscriptions
- Subscriptions listen to Events and can be used to react to certain Events with running custom Service scripts.
- To follow-up on Timers and Schedulers, a new Subscription must be created, listening to any related Event fired.
- Add a new Subscription to the Thing with
![image image](/t5/image/serverpage/image-id/63574i8ED8CE333A6C70DE/image-size/large?v=v2&px=999)
- As the Subscription is usually listening to the Thing that it is configured on, the Source has to be left empty. When listening to other Entities' Subscriptions the corresponding Entity can be picked in the Source Entity picker.
- Ensure to check the Enabled checkbox to actually enable the Subscription and allow it for executing code in the Script area.
- The following Script will log into the ScriptLog once the Timer Event is fired
![image image](/t5/image/serverpage/image-id/63567i9BF5D953B3DB776D/image-size/large?v=v2&px=999)
- The following Script will log into the ScriptLog once the ScheduledEvent Event is fired
![image image](/t5/image/serverpage/image-id/63570i4601F82B6D6F674C/image-size/large?v=v2&px=999)
Last update:
Mar 01, 2018
09:57 AM