ChangeJobStates(Int32,Int32[],Nullable<JobStateCode>,Nullable<DateTime>,Nullable<Int32>,Nullable<Boolean>,String) Method
- Last UpdatedNov 06, 2025
- 2 minute read
The ChangeJobStates() method sets the job state for the specified jobs, or to all jobs in the work orders to which the jobs belong.
This overload of the method uses a list of row IDs from the Job table to identify the jobs.
'Declaration
Public Overloads Shared Sub ChangeJobStates( _
ByVal sessionId As Integer, _
ByVal jobList() As Integer, _
ByVal stateCd As Nullable(Of JobStateCode), _
ByVal reqFinishTime As Nullable(Of Date), _
ByVal jobPriority As Nullable(Of Integer), _
ByVal applyToAllJobs As Nullable(Of Boolean), _
ByRef warningMessage As String _
)
'Usage
Dim sessionId As Integer
Dim jobList() As Integer
Dim stateCd As Nullable(Of JobStateCode)
Dim reqFinishTime As Nullable(Of Date)
Dim jobPriority As Nullable(Of Integer)
Dim applyToAllJobs As Nullable(Of Boolean)
Dim warningMessage As String
JobExec.ChangeJobStates(sessionId, jobList, stateCd, reqFinishTime, jobPriority, applyToAllJobs, warningMessage)
public static void ChangeJobStates(
int sessionId,
int[] jobList,
Nullable<JobStateCode> stateCd,
Nullable<DateTime> reqFinishTime,
Nullable<int> jobPriority,
Nullable<bool> applyToAllJobs,
out string warningMessage
)
Parameters
- sessionId
- Required. Holds the session ID and thus the user who is making this method call.
- jobList
- Required. Holds an array of row IDs to identify the job records in the Job table whose state is being updated.
- stateCd
- Optional. Holds the JobStateCode enumeration that indicates the new job state.
- reqFinishTime
- Optional. Holds the required completion date/time in local time.
- jobPriority
- Optional. Holds an integer that indicates the operation priority.
- applyToAllJobs
- Optional. Holds a flag that, if set to true, specifies that the change should be applied to all the jobs in a work order to which this job belongs. Defaults to false.
- warningMessage
- Output. Holds a returned message about any error that occurs while changing the state of the job.
If a non-null value for the supplied state code, required finish time, and/or job priority is supplied, those values are updated for the identified job. The supplied values are also updated to all other jobs in a work order if the ApplyToAllJobs flag is set to true. If any of the jobs are on hold (6) and the user (the user on this session context) does not have a privilege to change the status of a job that is on hold, the values for all the jobs are left unchanged.
A warning message is sent back via the warningMessage parameter if any of the following conditions are true:
- The state of a job identified by a the supplied row ID is On Hold(6), and/or the ApplyToAllJobs flag is set to true and one of the jobs in the work order is On Hold(6), and the user does not have a “May change hold status” privilege (PrivId:180) to change the status of a job that is currently on hold.
- The state of a supplied job and/or one of the jobs in the work order is currently Running(3), Completed(4) or Cancelled(7).
For the method to succeed:
- The supplied job state code must not be Running(3), Completed(4), Suspended(5), Bypassed(8), or Superseded(9).
- The jobs identified by the supplied row IDs exist in the database.