Skip to main content
Version: V2 (Ignition 8.1)

system.mes.shift.startShift

Description

Starts a Shifts. This creates a new Shift Records entry with the given start 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 startDateMillis; if omitted, the shift starts now.

# Start by shift ID (now)
system.mes.shift.startShift(shiftId=shiftId)

# Start by shift ID at a specific time
system.mes.shift.startShift(shiftId=shiftId, startDateMillis=startDateMillis)

# Start by location and name (now)
system.mes.shift.startShift(locationIdOrPath=locationIdOrPath, name=name)

# Start by location and name at a specific time
system.mes.shift.startShift(locationIdOrPath=locationIdOrPath, name=name, startDateMillis=startDateMillis)

Parameters

ParameterTypeNullableDescription
shiftIdString (ULID)YesThe ID of the shift to start.
locationIdOrPathStringYesThe location ID or path where the shift is defined.
nameStringYesThe name of the shift to start.
startDateMillisLongYesStart time in milliseconds since epoch. Defaults to now if omitted.

Returns

Returns a JSON representation of the created shift record.

NameTypeDescription
startDateDateTimeActual start date/time when the shift began.
endDateDateTimeActual end date/time when the shift ended (until stopped).
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

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

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

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

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