system.mes.shift.stopShift
Description
Stops a Shifts. This updates the current Shift Records entry with the given end time (optional; defaults to now).
Permissions
This method requires the SHIFT.EXECUTE permission.
Syntax
Identify the shift by either shiftId, or both locationIdOrPath and name. Optionally provide endDateMillis; if omitted, the shift stops now.
# Stop by shift ID (now)
system.mes.shift.stopShift(shiftId=shiftId)
# Stop by shift ID at a specific time
system.mes.shift.stopShift(shiftId=shiftId, endDateMillis=endDateMillis)
# Stop by location and name (now)
system.mes.shift.stopShift(locationIdOrPath=locationIdOrPath, name=name)
# Stop by location and name at a specific time
system.mes.shift.stopShift(locationIdOrPath=locationIdOrPath, name=name, endDateMillis=endDateMillis)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
shiftId | String (ULID) | Yes | The ID of the shift to stop. |
locationIdOrPath | String | Yes | The location ID or path where the shift is defined. |
name | String | Yes | The name of the shift to stop. |
endDateMillis | Long | Yes | End time in milliseconds since epoch. Defaults to now if omitted. |
Returns
Returns a JSON representation of the updated shift record.
| Name | Type | Description |
|---|---|---|
startDate | DateTime | Actual start date/time when the shift began. |
endDate | DateTime | Actual end date/time when the shift ended (set on stop). |
status | String (Enum) | Current status (IDLE, ACTIVE, CLOSED, VERIFIED). |
locationId | String (ULID) | The location where the shift runs. |
shiftId | String (ULID) | The shift configuration this record belongs to. |
id | String (ULID) | The ULID of the shift record. |
notes | String | Notes related to the record. |
enabled | Boolean | Indicates if the record is active and enabled. |
spare1 | String | Additional field for user-defined context. |
spare2 | String | Additional field for user-defined context. |
spare3 | String | Additional 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)