StartShift(Int32,Int32,Int32,DateTime) Method
- Last UpdatedMar 17, 2026
- 3 minute read
The StartShift() method starts or ends a shift for the specified entity and its children.
Note: This overload of the method is no longer supported. It will be removed in a future release. Instead, use the overload that includes the newShiftEndUtc input parameter.
'Declaration
<ObsoleteAttribute("This method should not be used and will be removed in releases higher than 7.0")>
Public Overloads Shared Sub StartShift( _
ByVal sessionId As Integer, _
ByVal entId As Integer, _
ByVal shiftId As Integer, _
ByVal dtStartTime As Date _
)
[Obsolete("This method should not be used and will be removed in releases higher than 7.0")]
public static void StartShift(
int sessionId,
int entId,
int shiftId,
DateTime dtStartTime
)
Parameters
- sessionId
- Required. Holds the session ID and thus the user who is making this method call.
- entId
- Required. Holds the ID the entity on which to start or end the shift.
- shiftId
- Required. Holds the ID of the shift to start or end.
- dtStartTime
- Optional. Holds the date/time on which to change the shift, in the local time of the MES database server. If null is supplied, the date/time defaults to the current date and time.
The specified entity has its shift changed even if the entity does not have its canSchedShifts flag set to true. This method cascades the shift ID and shift start recursively to all its child entities that do not have canSchedShifts flag set to true, which implies they define their own shift schedule. As soon as a child entity does have the canSchedShifts flag set to true, then the cascading does not continue for any of that child’s descendants to change the shift. If the supplied shift ID or the shift start times do not match those of the existing shift for an entity, then the following tables are updated:
- Utilization (only if this entity is capable of capturing utilization) – A shift start creates a new Util_History record if the entity is configured to create a new utilization event upon a shift change (utilization state and reason comes from the the Util_Exec table).
If the supplied shift is ending on this entity and the entity is configured to have a shift end reason code (the shift_end_reas_cd column in the Util_Exec table) and there is no shift adjacent to current shift that is starting immediately, then a new utilization event record with the shift end reason code is created in the Util_History table.
If the supplied shift is starting another shift on this entity and the entity is configured to have a shift start reason code (the shift_start_reas_cd column in the Util_Exec table), then a new utilization event record with the shift start reason code is created in the Util_History table.
If both shift end reason code and shift start reason code is configured for a utilization entity, and while changing the shifts the Middleware ignores the shift end reason code, and it does not create a new utilization row pertaining to the shift end reason code, then a new utilization record is created only for the shift start reason code. If no such default reason code is configured for a shift start/end, then no record is created in the Util_History table.
- Labor (only if this entity is capable of capturing labor) – The duration for the active records in the Active_Labor table are updated with the current date and time by subsequently closing all the active labor records pertaining to the current shift. A new labor usage record containing the supplied shift information with the active flag set to true is created for all the users who are logged onto the system and are currently active.
The process specified above is recursively executed for all the child entities until it reaches the entity that can schedule shifts on its own.