Skip to main content

system.mes.shift.saveShiftRecord

Description

Creates or updates a Shift Records in the system based on the provided parameters.

Syntax

system.mes.shift.saveShiftRecord(**record_data)

Parameters

ParameterTypeNullableDescription
locationIdString (ULID)FalseThe ULID of the location where the shift runs.
shiftIdString (ULID)FalseThe ULID of the shift configuration this record belongs to.
startDateDateTimeTrueActual start date/time when the shift began.
endDateDateTimeTrueActual end date/time when the shift ended.
statusString (Enum)FalseCurrent status (IDLE, ACTIVE, CLOSED, VERIFIED).
idString (ULID)TrueThe ULID of the shift record (optional, used for updates).
notesStringTrueNotes related to the record.
enabledBooleanTrueIndicates if the record is active and enabled. Default true.
spare1StringTrueAdditional field for user-defined context.
spare2StringTrueAdditional field for user-defined context.
spare3StringTrueAdditional field for user-defined context.

Returns

Returns a JSON representation of the saved shift record.

Code Examples

# Create a new record (typically use startShift instead)
rec = system.mes.shift.newShiftRecord()
rec['shiftId'] = '01JAP8RJBN-8ZTPXSGY-J9GSDPE1'
rec['locationId'] = '01JAP8RJBN-8ZTPXSGY-J9GSDPE1'
rec['status'] = 'ACTIVE'

saved = system.mes.shift.saveShiftRecord(**rec)
print(saved)

# Update an existing record
rec2 = system.mes.shift.newShiftRecord()
rec2['id'] = saved.id
rec2['status'] = 'CLOSED'

updated = system.mes.shift.saveShiftRecord(**rec2)
print(updated)