PurgePropertyHistory
Description
When a logged property is updated, the data is written to a value stream that is associated with the Thing. You can use the PurgePropertyHistory service to purge the historical data from one logged property for a specified time range.
The property history of the Thing on which the service is called will be purged, but the property history of other Things will not be purged. If you want to purge historical data for multiple Things, you must call the service on each Thing.
By default, this purge runs asynchronously.
Input
Parameter Name
Description
Base Type
propertyName
Name of the property for which historical data should be purged.
STRING
startDate
The start date, including the specified date, from which historical data should be purged.
DATETIME
endDate
The end date, including the specified date, up to which historical data should be purged.
DATETIME
immediate
If false, the purge runs asynchronously. The default value is false. If you set it to true, the purge will run synchronously.
BOOLEAN
Output
None.
Example
In the following example, the Thing has a logged property named propertyA-Logged that has been updated multiple times and was collecting historical data.
The input parameters can be passed inline as shown below:
// Purging historical data between the given start and end dates
Things["TestThing"].PurgePropertyHistory({
propertyName: 'propertyA-Logged' /* STRING */,
startDate: '2024-05-12T16:58:28.000Z' /* DATETIME */,
endDate: 'Date.now()' /* DATETIME */,
immediate: true /* BOOLEAN {"defaultValue":false} */
});
Or, you can construct an infotable.
// Params for purging historical data from the past year
var purgeHistoryParams = {
propertyName: 'propertyA-Logged' /* STRING */,
startDate: new Date(new Date().setFullYear(new Date().getFullYear() - 1)),
endDate: Date.now(),
immediate: true /* BOOLEAN */
};

Things["TestThing"].PurgePropertyHistory(purgeHistoryParams);
Was this helpful?