Add Method (JobHistory)
- Last UpdatedMar 17, 2026
- 3 minute read
The Add() method adds a new job history record to the Job_History table.
This method is used for inserting historical job records into the Job_History table. To start a new job on an entity, use the JobExec.StartJob() method.
'Declaration
Public Shared Sub Add( _
ByVal sessionId As Integer, _
ByVal entityId As Integer, _
ByVal woId As String, _
ByVal operId As String, _
ByVal seqNo As Integer, _
ByVal jobStartUtc As Date, _
ByVal jobPos As Integer, _
ByVal itemId As String, _
ByVal spare1 As String, _
ByVal spare2 As String, _
ByVal spare3 As String, _
ByVal spare4 As String, _
ByRef lastEditAt As Nullable(Of Date) _
)
'Usage
Dim sessionId As Integer
Dim entityId As Integer
Dim woId As String
Dim operId As String
Dim seqNo As Integer
Dim jobStartUtc As Date
Dim jobPos As Integer
Dim itemId As String
Dim spare1 As String
Dim spare2 As String
Dim spare3 As String
Dim spare4 As String
Dim lastEditAt As Nullable(Of Date)
JobHistory.Add(sessionId, entityId, woId, operId, seqNo, jobStartUtc, jobPos, itemId, spare1, spare2, spare3, spare4, lastEditAt)
public static void Add(
int sessionId,
int entityId,
string woId,
string operId,
int seqNo,
DateTime jobStartUtc,
int jobPos,
string itemId,
string spare1,
string spare2,
string spare3,
string spare4,
out Nullable<DateTime> lastEditAt
)
Parameters
- sessionId
- Required. Holds the session ID and thus the user who is making this method call.
- entityId
- Required. Holds the entity ID of the job.
- woId
- Required. Holds the work order ID of the job.
- operId
- Required. Holds the operation ID of the job.
- seqNo
- Required. Holds the sequence number of the job.
- jobStartUtc
- Required. Holds the start date/time of the job, in UTC.
- jobPos
- Required. Holds the position of the job.
- itemId
- Required. Holds the item ID of the job.
- spare1
- Optional. Holds the contents of the user-defined spare1 field.
- spare2
- Optional. Holds the contents of the user-defined spare2 field.
- spare3
- Optional. Holds the contents of the user-defined spare3 field.
- spare4
- Optional. Holds the contents of the user-defined spare4 field.
- lastEditAt
Output. Holds the returned date/time when this record was added. The lastEditAt parameter is used by other methods that modify or delete this type of record for optimistic concurrency control.
Creates the hourly bucket if the job start is successful and the can_capture_oee flag is turned on for the entity.
The JobExec class StartJob(), PauseJob(), and EndJob() methods operate on the current state of the entity. In other words, if JobExec.StartJob() is called, the job is set to be running at the current time. If a time in the past is supplied when starting a job, the current state of the entity is set to Running with the time the job was started in the past. JobHistory.Add() operates on historical job records and is not a replacement for JobExec.StartJob(). The direct insert on the JobHistory.Add() method is used to record jobs that occurred in the past, which does not require the current state of the entity to be modified. For example, you can use the JobHistory.Add() method to specify that a job was started on an entity on 1/1/2017 and ended on 1/2/2017.
This method will return an error if any of the following conditions are met:
- The supplied job and the start time overlaps with another job that was running on the entity at the same job position.
- The supplied job was running on a different job position at the same time on the same entity.
- The supplied job was running on a different entity at the same time.
Observe the following input parameter rules:
- Required non-DB* parameters: Must pass a value. Cannot be empty or null.
- Optional non-DB* parameters: Either enter a value or pass a null. If passing a null and a default value has been defined, the default value will be used for the parameter.