PurgeSelectedPropertyHistory
Description
When logged properties are updated, their data is written to a value stream that is associated with the Thing. You can use the PurgeSelectedPropertyHistory service to purge the historical data of a specified list of logged properties of a Thing for a specified time range.
The property history of the Thing on which the service is called will be purged. If you want to purge the historical data for multiple Things, you must call the service on each Thing.
This purge runs synchronously.
Input
Parameter name
Description
Base Type
startDate
The start date, including the specified date, from which the historical should be purged.
DATETIME
endDate
The last date, including the specified date, for which the historical data should be purged.
DATETIME
propertiesToPurge
Names of the properties for which data should be purged. The names of the properties are passed in an infotable. The expected Data Shape for the infotable is PropertyList.
INFOTABLE
Output
None.
Example
In the following example, TestThing has three logged properties: propertyA-Logged, propertyB-Logged, and propertyC-Logged. These properties been updated multiple times and have collected historical data. The following snippet can be used to purge the history of a specified subset of the logged properties of the Thing:
// Creating an infotable using the required datashape for specifying the names of properties to purge
var propertiesToPurge = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape( {
infoTableName : "InfoTable",
dataShapeName : "PropertyList"
});

// Adding the names of properties to the infotable created above
propertiesToPurge.AddRow({ propertyName: "propertyA-Logged" });
propertiesToPurge.AddRow({ propertyName: "propertyB-Logged" });

// Purging history
Things["TestThing"].PurgeSelectedPropertyHistory({
propertiesToPurge: propertiesToPurge, /* INFOTABLE */
startDate: 0, /* DATETIME */
endDate: dateAddYears((new Date()),1000) /* DATETIME */
});
Was this helpful?