Skip to main content

system.mes.shift.stopShift

Description

Stops a Shifts. This updates the current Shift Records entry with the given end time (optional; defaults to now).

Syntax

system.mes.shift.stopShift(shiftId)
system.mes.shift.stopShift(shiftId, endDateMillis)
system.mes.shift.stopShift(locationIdOrPath, name)
system.mes.shift.stopShift(locationIdOrPath, name, endDateMillis)

Parameters

Method 1: Stop by Shift ID (Now)

ParameterTypeNullableDescription
shiftIdString (ULID)FalseThe ID of the shift to stop.

Method 2: Stop by Shift ID and End Date (Millis)

ParameterTypeNullableDescription
shiftIdString (ULID)FalseThe ID of the shift to stop.
endDateMillisLongFalseEnd time in milliseconds since epoch.

Method 3: Stop by Location and Name (Now)

ParameterTypeNullableDescription
locationIdOrPathStringFalseThe location ID or path where the shift is defined.
nameStringFalseThe name of the shift to stop.

Method 4: Stop by Location, Name, and End Date (Millis)

ParameterTypeNullableDescription
locationIdOrPathStringFalseThe location ID or path where the shift is defined.
nameStringFalseThe name of the shift to stop.
endDateMillisLongFalseEnd time in milliseconds since epoch.

Returns

Returns a JSON representation of the updated shift record.

NameTypeDescription
startDateDateTimeActual start date/time when the shift began.
endDateDateTimeActual end date/time when the shift ended (set on stop).
statusString (Enum)Current status (IDLE, ACTIVE, CLOSED, VERIFIED).
locationIdString (ULID)The location where the shift runs.
shiftIdString (ULID)The shift configuration this record belongs to.
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

# Stop by shift ID (now)
record = system.mes.shift.stopShift('01JAP8RJBN-8ZTPXSGY-J9GSDPE1')
print(record)

# Stop by shift ID at a specific time
ts = 1735693200000
record = system.mes.shift.stopShift('01JAP8RJBN-8ZTPXSGY-J9GSDPE1', ts)
print(record)

# Stop by location and name (now)
record = system.mes.shift.stopShift('DairyCo/Plant1/Line1', 'Morning Shift')
print(record)

# Stop by location and name at a specific time
record = system.mes.shift.stopShift('DairyCo/Plant1/Line1', 'Morning Shift', ts)
print(record)