CloneJob(Int32,String,String,Int32,String,String,String,Nullable<Int32>,Nullable<Double>,Nullable<Double>,Nullable<Int32>,Nullable<DateTime>,String,String,String) Method
- Last UpdatedNov 06, 2025
- 4 minute read
The CloneJob() method creates a copy of the specified job and all of its dependent data.
This overload of the method uses the entity name and site name to identify the target entity on which the new job will be run.
'Declaration
Public Overloads Shared Sub CloneJob( _
ByVal sessionId As Integer, _
ByVal woId As String, _
ByVal operId As String, _
ByVal seqNo As Integer, _
ByVal userId As String, _
ByVal newWoId As String, _
ByVal newOperId As String, _
ByVal newSeqNo As Nullable(Of Integer), _
ByVal reqQty As Nullable(Of Double), _
ByVal startQty As Nullable(Of Double), _
ByVal newStateCd As Nullable(Of Integer), _
ByVal reqFinishTime As Nullable(Of Date), _
ByVal targetEntName As String, _
ByVal targetSiteName As String, _
ByVal statusNotes As String _
)
'Usage
Dim sessionId As Integer
Dim woId As String
Dim operId As String
Dim seqNo As Integer
Dim userId As String
Dim newWoId As String
Dim newOperId As String
Dim newSeqNo As Nullable(Of Integer)
Dim reqQty As Nullable(Of Double)
Dim startQty As Nullable(Of Double)
Dim newStateCd As Nullable(Of Integer)
Dim reqFinishTime As Nullable(Of Date)
Dim targetEntName As String
Dim targetSiteName As String
Dim statusNotes As String
JobExec.CloneJob(sessionId, woId, operId, seqNo, userId, newWoId, newOperId, newSeqNo, reqQty, startQty, newStateCd, reqFinishTime, targetEntName, targetSiteName, statusNotes)
public static void CloneJob(
int sessionId,
string woId,
string operId,
int seqNo,
string userId,
string newWoId,
string newOperId,
Nullable<int> newSeqNo,
Nullable<double> reqQty,
Nullable<double> startQty,
Nullable<int> newStateCd,
Nullable<DateTime> reqFinishTime,
string targetEntName,
string targetSiteName,
string statusNotes
)
Parameters
- sessionId
- Required. Holds the ID of the session from which the method is being called.
- woId
- Required. Holds the work order ID of the job to be cloned.
- operId
- Required. Holds the operation ID of the job to be cloned.
- seqNo
- Required. Holds the sequence number of the job to be cloned.
- userId
- Required. Holds the ID of the user who is performing this action.
- newWoId
- Optional. Holds the work order ID of the new job.
- newOperId
- Optional. Holds the operation ID of the new job.
- newSeqNo
- Optional. Holds the sequence number of the new job.
- reqQty
- Optional. Holds the required quantity of the new job. Defaults to the same value as the cloned job.
- startQty
- Optional. Holds the start quantity of the new job. Defaults to the same value as the cloned job.
- newStateCd
Optional. Holds the initial state of the new job as a variant (long).
Only the following values are allowable:
1 (NEW)
2 (READY)
5 (SUSPENDED)
6 (ONHOLD)
- reqFinishTime
- Optional. Holds the required finish time of the new job. Defaults to same value as the cloned job.
- targetEntName
- Optional. Holds the name of the entity on which the new job is targeted to run. Defaults to same entity as the cloned job.
- targetSiteName
- Optional. Holds the site name of the entity on which the new job is targeted to run. Defaults to same entity as the cloned job.
- statusNotes
- Optional. Holds notes about the new job that is being created. Defaults to “Created by Job Clone”.
At least one of the new work order, operation, or sequence number must be specified and different from the cloned values. Also, the user ID must be valid and the user must have sufficient privileges to clone jobs.
For the method to succeed, the new job cannot already exist in the database, and the cloned job must exist.
If new work order ID is specified, then the oper_id and seq_no will remain the same for the new job being created. If a new work order is NOT specified, then the wo_id and oper_id will stay the same and the next available seq_no (i.e., new_seq_no) will be applied to the new job.
The optional parameters can be used to set change values in the new job from those in the cloned job. If they are not specified, then the column values from the original job are used with the following exceptions:
run_ent_id = null
sched_pinned = false
qty_prod = 0
qty_prod_erp = null
qty_rejected = 0
qty_ rejected_erp = null
concurrent_link = 0
act_start_time = null
act_finish_time = null
sched_start_time = null
sched_finish_time = null
The latest start time will be calculated by using req_qty and req_finish_time.
All rows in the following tables will also be cloned: Job_Bom, Job_Bom_Step, Job_Spec, Job_Step, Job_Route, and Job_Attr, with the following exceptions:
Job_Route table: Here, if the new_wo_id is the same as the wo_id (the new job will be added to the same work order of the cloned job), then a new record is added with a new seq_no; everything else remains same. If the new_wo_id is different then wo_id (the new job will be added to a new work order), the input job row is cloned before a row in the Job_Route table is cloned.
Job_spec.act_spec_value is set = null
Job_Step.act_time is set = null
Job_ Step.complete is set = 0