Schedule Operations on a Thingworx DataTable
A Scheduler is a specific entity for specifying recurring events on Thingworx platform. It doesn’t do anything on it’s own – it is simply a container for a schedule definition that can be referred to by other entities that want to operate a service on a recurring basis.
Creating and Naming Schedulers
There isn’t much to creating a scheduler entity. The naming of schedulers might require some consideration if there is a desire to reuse them. An argument could be made that schedulers should be named for the frequency they issue if they are organized and used based on that criterion. “Monthly”, “Weekly”, “Daily” and so on.
However, if they aren’t intended to be used that way it is best to name them in association with the services they will trigger. In my experience it is far more likely that a scheduler frequency or start time will be adjusted to meet the specific needs of a particular service, and so I favor this approach.
The CRON spec has a helper that makes setting the recurrence painless.
You should specify a system user account to run a scheduler that is used for any automated processes on the platform. If one is not defined, you should read the documentation and create one with just the minimum access required to fill the role.
A subscription entity can subscribe to another subscription. Use with care. I avoid.
How do you tell a scheduler to run a service?
You don’t. Thingworx has this concept the other way around. You tell a Service to use a Scheduler. Let’s say you have an entity containing a service you want to schedule:
- Go to the Subscriptions tab.
- Name it in association with the subscription name
- Pick “Other Entity” for source
- Select your scheduler entity
- Enable it or remind yourself that you will need to come back and do this.
Under Inputs, select ScheduledEvent
Have you noticed that the Subscriptions UI looks a lot like Services? You will need to write a service to call your service. It will look something like this:
retentionUnit: 'week' /* STRING */,
retentionValue: 1 /* NUMBER */
This will trim any rows previous to 7 days before midnight of the current day in which it is run. The CRON for this is set in the scheduler General Information tab as
0 0 0 1/1 * ?