system.mes.oee.scheduleOeeRecordPruning
Description
Schedules OEE records for pruning by setting their toBePruned flag to true. Records matching the given location and date criteria will be permanently deleted during the next nightly maintenance window.
This method does not delete records immediately. Call system.mes.oee.unscheduleOeeRecordPruning() to cancel before the maintenance window runs.
All four OEE record types are scheduled together: production records, state records, mode records, and alarm records.
Permissions
This method requires the OEE (Admin) permission.
Syntax
# Run method with prune date as Date object
system.mes.oee.scheduleOeeRecordPruning(locationIdsOrPaths, pruneBeforeDate)
# Run method with prune date in milliseconds as Long object
system.mes.oee.scheduleOeeRecordPruning(locationIdsOrPaths, pruneBeforeDateMillis)
Parameters
Provide the prune cut-off with either pruneBeforeDate or pruneBeforeDateMillis; exactly one is required.
| Parameter | Type | Nullable | Description |
|---|---|---|---|
locationIdsOrPaths | Set<String> | Yes | A set of location IDs or paths whose records should be scheduled for pruning. Pass null or empty to target all locations. |
pruneBeforeDate | Date | Yes | Records with an end date before this date will be scheduled for pruning. Provide either this or pruneBeforeDateMillis. |
pruneBeforeDateMillis | Long | Yes | Records with an end date before the date defined by Instant.ofEpochMilli will be scheduled for pruning. Provide either this or pruneBeforeDate. |
Returns
The total number of OEE records (across all record types) 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 locations
locationsToPrune = {"Enterprise/Site/Area/Line1", "Enterprise/Site/Area/Line2"}
count = system.mes.oee.scheduleOeeRecordPruning(locationsToPrune, cutoffDate)
print "Scheduled", count, "record(s) for pruning. They will be deleted during the next nightly maintenance window."
print "Call system.mes.oee.unscheduleOeeRecordPruning() to cancel."
# Schedule records for all locations
# count = system.mes.oee.scheduleOeeRecordPruning(set(), cutoffDate)