Skip to main content

system.mes.shift.newShift

Description

Generates an empty non-persisted Shifts object to provide the structure required by the API to save a new record into the database. Use with saveShift.

Syntax

system.mes.shift.newShift()

Parameters

ParameterTypeNullableDescription
None--This method does not take any parameters.

Returns

Returns a JSON representation of the newly created shift object. The following is a list of keys and default values:

KeyDefault Value
namenull
descriptionnull
shiftScheduleNamenull
shiftScheduleSourceIGNITION_SCHEDULE
locationIdnull
locationPathnull
currentRecordIdnull
runningConflictStrategySTOP_PREVIOUS
startTriggerExpressionnull
startTriggerTypeRISING_EDGE
stopTriggerExpressionnull
stopTriggerTypeFALLING_EDGE
idnull
notesnull
enabledtrue
spare1null
spare2null
spare3null

Valid values for shiftScheduleSource are IGNITION_SCHEDULE, IGNITION_EXPRESSION.

Code Examples

# Create an empty Shift object
shift = system.mes.shift.newShift()

# Populate required fields
shift['locationId'] = '01JAP8RJBN-8ZTPXSGY-J9GSDPE1'
shift['name'] = 'Morning Shift'
shift['shiftScheduleName'] = 'Weekday Schedule'
shift['shiftScheduleSource'] = 'IGNITION_SCHEDULE'
shift['startTriggerType'] = 'RISING_EDGE'
shift['stopTriggerType'] = 'FALLING_EDGE'

# Save the shift
saved = system.mes.shift.saveShift(**shift)
print(saved)