Skip to main content

system.mes.shift.getCurrentShiftRecord

Description

Gets the current Shift Records at the given location. Optionally, you can specify a timestamp (milliseconds since epoch) to get the record active at that moment.

Syntax

system.mes.shift.getCurrentShiftRecord(locationIdOrPath)
system.mes.shift.getCurrentShiftRecord(locationIdOrPath, timestampMillis)

Parameters

Method 1: By Location at Current Time

ParameterTypeNullableDescription
locationIdOrPathStringFalseThe location ID or path to find the current shift record for.

Method 2: By Location at Specific Timestamp

ParameterTypeNullableDescription
locationIdOrPathStringFalseThe location ID or path to find the current shift record for.
timestampMillisLongTrueThe timestamp (ms since epoch) to evaluate. If null, uses the current time.

Returns

Returns a JSON representation of the shift record. Returns nothing if no record is found.

NameTypeDescription
startDateDateTimeActual start date/time when the shift began.
endDateDateTimeActual end date/time when the shift ended.
statusString (Enum)Current status (IDLE, ACTIVE, CLOSED, VERIFIED).
locationIdString (ULID)The ULID of the location where the shift runs.
shiftIdString (ULID)The ULID of the shift configuration for this record.
shiftNameStringThe name of the shift configuration.
idString (ULID)The ULID of the shift record.
notesStringNotes related to the record.
enabledBooleanIndicates if the record is active and enabled.
spare1StringAdditional field for user-defined context.
spare2StringAdditional field for user-defined context.
spare3StringAdditional field for user-defined context.

Code Examples

# Current record for a location
rec = system.mes.shift.getCurrentShiftRecord('DairyCo/Plant1/Line1')
print(rec)

# Current record at a given timestamp
recAtTime = system.mes.shift.getCurrentShiftRecord('DairyCo/Plant1/Line1', 1735689600000)
print(recAtTime)