Skip to main content
Version: V3 (Ignition 8.3)

system.mes.meter.scheduleMeterRecordPruning

Description

Schedules meter records for pruning by setting their toBePruned flag to true. Records matching the given equipment and date criteria will be permanently deleted during the next nightly maintenance window.

This method does not delete records immediately. Call system.mes.meter.unscheduleMeterRecordPruning() to cancel before the maintenance window runs.

Permissions

This method requires the METERING (Admin) permission.

Syntax

system.mes.meter.scheduleMeterRecordPruning(equipmentIdsOrPaths, pruneBeforeDate)

Parameters

ParameterTypeNullableDescription
equipmentIdsOrPathsList<String>FalseA list of equipment IDs or paths whose records should be scheduled for pruning.
pruneBeforeDateDateFalseRecords with an end date before this date will be scheduled for pruning.

Returns

The number of records scheduled for pruning as an integer.

Code Examples

from java.util import Date
from java.util.concurrent import TimeUnit

# Define the cutoff date (e.g., 90 days ago)
cutoffMillis = Date().getTime() - TimeUnit.DAYS.toMillis(90)
cutoffDate = Date(cutoffMillis)

# Schedule records for specific equipment
equipmentToPrune = ["Enterprise/Site/Area/Line1/Compressor1"]

count = system.mes.meter.scheduleMeterRecordPruning(equipmentToPrune, cutoffDate)
print "Scheduled", count, "record(s) for pruning. They will be deleted during the next nightly maintenance window."
print "Call system.mes.meter.unscheduleMeterRecordPruning() to cancel."