Skip to main content
Version: V2 (Ignition 8.1)

system.mes.oee.rebuildCalculationRecords

Description

Deletes existing pre-computed OEE calculation records in the specified range and regenerates them from raw data. This is useful for correcting stale data or backfilling historical periods after raw record corrections. If an OeeCalculationConfig exists for the location and period type, its latestCalculationTimestamp is updated to the end date of the last generated record.

Permissions

This method requires the OEE.WRITE.SAVE permission.

Syntax

system.mes.oee.rebuildCalculationRecords(locationIdOrPath, periodType, startDate, endDate)

Parameters

ParameterTypeNullableDescription
locationIdOrPathStringFalseLocation ID (ULID) or path.
periodTypeStringFalsePeriod granularity: "HOUR", "DAY", "WEEK", "MONTH", or "SHIFT".
startDateDateFalseStart of the rebuild range (inclusive).
endDateDateFalseEnd of the rebuild range (inclusive).

Returns

A JSON ApiResponse object indicating success or failure.

NameTypeDescription
successBooleanTrue if the records were rebuilt successfully.
messageStringA message describing the result.
errorStringError details if the operation failed, otherwise null.

Code Examples

import system.date
from java.util import Date

# Rebuild daily records for the past 7 days
location = "Enterprise/Site/Line1"
endDate = system.date.midnight(Date())
startDate = system.date.addDays(endDate, -7)

result = system.mes.oee.rebuildCalculationRecords(location, "DAY", startDate, endDate)
if result['success']:
print "Records rebuilt successfully"
else:
print "Error:", result['error']