system.mes.meter.pruneMeterRecords
Description
Permanently deletes Meter Records that ended before a specified date for the given list of equipment. Only completed records (records with an end date) are pruned.
Permissions
This method requires the METERING.WRITE.DELETE permission.
Syntax
system.mes.meter.pruneMeterRecords(equipmentIdsOrPaths, pruneBeforeDate)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
equipmentIdsOrPaths | List<String> | False | List of equipment IDs or paths whose records should be pruned. |
pruneBeforeDate | Date | False | Records that ended before this date will be permanently deleted. |
Returns
Returns an integer representing the number of Meter Records that were pruned.
Code Examples
# Prune all Meter Records older than 90 days for a specific equipment
pruneBeforeDate = system.date.addDays(system.date.now(), -90)
prunedCount = system.mes.meter.pruneMeterRecords(
['Enterprise/Site/Line1'],
pruneBeforeDate
)
print("Records pruned:", prunedCount)