Summary
The Job object provides access to properties and methods to interact with a Workflow Manager (Classic) job.
Discussion
A Job is a single unit of work that is carried out within an organization. It may have one or many people working on it. It can work with a single dataset, multiple datasets, or no data at all. A Job is created based on a template known as a Job Type, which is configured with the desired properties and components (such as the Workflow and Maps) that will be used in the job.
Properties
Property | Explanation | Data Type |
assignedTo (Read and Write) | The user name or group to which the job is assigned. | String |
assignedType (Read and Write) | The type of assignment for the job. Below is a list of valid strings to use when setting the job assignment. If an invalid string is used, the job will default to unassigned.
| String |
createdBy (Read and Write) | The user name of the user who created the job. | String |
createdDate (Read Only) | Returns the date the job was created. | DateTime |
currentSteps (Read Only) | Returns a list of step IDs representing the steps that are active in the workflow. | List |
description (Read and Write) | The description of the job. | String |
dueDate (Read and Write) | The date the job was scheduled to end. | DateTime |
endDate (Read Only) | Returns the date the job ended. | DateTime |
hasAOI (Read Only) | Returns True when the job has an area of interest defined. | Boolean |
hasLOI (Read Only) | Returns True when the job has a location of interest (point or polygon) defined. | Boolean |
ID (Read Only) | Returns the job ID. | Integer |
jobTypeID (Read Only) | Gets the ID of the job type for the job. | Integer |
name (Read and Write) | The job's name. | String |
notes (Read and Write) | The notes associated with the job to share information with other users. | String |
owner (Read and Write) | The user name of the user who owns the job. | String |
parent (Read and Write) | The ID of the parent job for the current job. | Integer |
parentVersion (Read and Write) | The name of the parent version of the job. | String |
percentComplete (Read Only) | Returns the percent completion for the job. | Double |
priority (Read and Write) | The priority of the job. | Integer |
startDate (Read and Write) | The date the job was scheduled to start. | DateTime |
startedDate (Read Only) | Returns the date the job was started. | DateTime |
status (Read and Write) | The status name for the job. The statuses available for use are those defined as status types in the Workflow Manager (Classic) database. | String |
versionExists (Read Only) | Returns True when a version exists for a job. | Boolean |
versionName (Read and Write) | The name of the version for the job. | String |
Method Overview
Method | Explanation |
addAttachment (storage_type, source_location) | Adds an attachment to the job. |
addDependency (depends_on_job_id, {held_on_type}, {held_on_value}, {dependent_on_type}, {dependent_on_value}) | Adds a dependency to a job to restrict progression of the job past a certain point until another job has progressed past a given point. |
addHold (hold_type_id, {comment}) | Adds a hold to a job to suspend job activity. |
deleteAttachment (attachment_id) | Deletes an attachment associated with the job. |
deleteJobMap () | Deletes the job map associated with the job. |
executeStep ({step_id}, {callback}) | Executes a step in the workflow. |
getAttachments () | Returns all attachments associated with the job as a list of Attachment objects. |
getExtendedPropertyTable (tableName) | Returns a single extended property table based on its fully qualified table name. |
getHolds () | Returns the holds associated with the job as a list of Hold objects. |
getPendingDays (consider_hold) | Returns the number of days that the job has been pending. This can also optionally consider the holds and subtract them from the number of days the job was pending. |
getWorkflow (jobID) | Returns a job's Workflow using the job ID. |
listExtendedProperties () | Lists the fully qualified name of all extended property and linked property tables associated with the job. |
logActivity (activity_type, {message}) | Logs an activity in the job history to describe an action on the job. |
markStepAsComplete ({step_id}, {callback}) | Marks a step in the workflow as complete. |
releaseHold (hold, {comment}) | Releases the hold associated with a job and marks it as an inactive hold. |
retrieveAttachment (attachment_id, destination_location) | Retrieves the file attachments associated with the job to a location on disk. |
retrieveJobMap (destination_location) | Retrieves the job map to a location on disk. |
save () | Saves any changes made to the job back to the Workflow Manager (Classic) database. |
sendNotification (notification_type) | Sends a notification based on an event in the job life cycle. |
setAOI (aoi) | Sets the area of interest (AOI) polygon for the job. |
setDataWorkspace (data_workspace_id) | Sets the data workspace for the job. |
setLOI (loi) | Sets the location of interest (LOI) for the job. The LOI can be either a point (POI) or polygon (AOI). |
setStepAsCurrent (step_id) | Sets a step in the workflow as the current active step. |
storeJobMap (source_location) | Saves a map in the Workflow Manager (Classic) database and associates it to the job as the job map to be used for editing. |
Methods
addAttachment (storage_type, source_location)
Parameter | Explanation | Data Type |
storage_type | The type of attachment to be added.
| String |
source_location | The file path or URL for the attachment to be added. | String |
The attachments provide a way to add information to the job. The following types of attachments can be added to a job:
- Embedded—The file is stored in the Workflow Manager (Classic) database.
- Linked—The link to the file path is stored in the Workflow Manager (Classic) database.
- URL—The URL link is stored in the database.
The following script adds a linked, embedded, and URL attachment to the job.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Add a linked file attachment
job.addAttachment('LINKED', r'c:\test\Requirements.doc')
# Add an embedded file attachment
job.addAttachment('EMBEDDED', r'c:\test\Field_Observation.png')
# Add an embedded file attachment
job.addAttachment('URL', 'http://www.esri.com')
addDependency (depends_on_job_id, {held_on_type}, {held_on_value}, {dependent_on_type}, {dependent_on_value})
Parameter | Explanation | Data Type |
depends_on_job_id | ID of the job on which the current job will depend. | Integer |
held_on_type | Indicates whether the current job (to which the dependency is being added) will be held at a step or status. When the job is held at a step, the step cannot be executed until the dependency is released. When the job is held at a status, the job's status cannot change until the dependency is released. The dependency is released when the other job reaches the step or status as defined in the dependency criteria. (The default value is STEP) | String |
held_on_value | The value of the step or status at which the current job will be held. This value can be the ID of a step as an integer or job status as a string. | Variant |
dependent_on_type | Indicates whether the current job (to which the dependency is being added) will be dependent on a step or status of the other job. When the dependent job is held at a step or status of the other job, the dependent job cannot progress until the other job reaches the step or status defined in the dependency. Once the other job reaches step or status as defined in the dependency criteria the dependency is released and the dependent job can progress. (The default value is STATUS) | String |
dependent_on_value | The value of the step or status of the other job on which the current job will be dependent. This value can be the ID of a step as an integer or job status as a string. (The default value is CLOSED) | Variant |
Job dependencies allow you to model relationships between jobs, allowing you to restrict progress of a job until another job has progressed past a certain point. Restrictions can be placed on the following parts of a job: Status or Step.
When the job that is restricting the workflow of another reaches the point defined in the dependency, the restricted job is automatically released and is able to work.
The following script adds the default dependency, a job step to status dependency and a job status to step dependency on the current job.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Add a dependency to job 99999 that holds it at the current step, until the status of job 55555 is Closed
job.addDependency(55555)
# Add a dependency to job 99999 that holds it at step 5, until the status of job 88888 is Working
job.addDependency(88888, 'STEP', 5, 'STATUS', 'WORKING')
# Add a dependency to job 99999 that holds it at status QAQC, until step 8 of job 77777 is active.
job.addDependency(77777, 'STATUS', 'QAQC', 'STEP', 8)
addHold (hold_type_id, {comment})
Parameter | Explanation | Data Type |
hold_type_id | The ID of the hold type template to be used to create the job hold. | Integer |
comment | The comment to be stored as a reason for adding the hold. | String |
Holds suspend the job activity for an indefinite amount of time until it is released. A hold can be applied to a job for reasons including the following:
- Insufficient funding
- Technical problems
- Missing data
- Lack of resources
The following script gets the hold types in the Workflow Manager (Classic) database and adds a budget hold to a job.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Get a list of Hold types in Workflow database
hold_types = conn.config.getHoldTypes()
# Access a Workflow Job
job = conn.getJob(99999)
# Find the id of Budget Hold hold type and add a hold on the job
for hold in hold_types:
if hold.name == 'Budget Hold':
job.addHold(hold.id,comment="Insufficient funds for digitization.")
deleteAttachment (attachment_id)
Parameter | Explanation | Data Type |
attachment_id | The ID of the attachment to be deleted. | Integer |
The attachments provide a way to add information to the job.
The following script deletes an attachment from the job.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Delete attachment with id = 1
job.deleteAttachment(1)
deleteJobMap ()
The job map has the layers used for editing required as part of the job.
The following script deletes the job map of a job.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Delete the job map of the job
job.deleteJobMap()
executeStep ({step_id}, {callback})
Parameter | Explanation | Data Type |
step_id | The ID of the step to be executed. The step ID is optional; if a step ID is not provided, the current step will be executed. | Integer |
callback | The callback argument passes a function that prompts the user for a response based on input from the step type. When executing a question step, for example, the callback takes the possible step response options and allows the user to choose the next step. It is also used when the next step in the workflow cannot be determined so a user can select the path to follow. | Function |
Return Value
Data Type | Explanation |
WorkflowExecutionResult | Returns a WorkflowExecutionResult object, which stores the step's return code. |
Provides a way to execute a step in the workflow.
The following script executes a step in the workflow and provides an example of a callback function that can be used during execution.
import arcpy
import sys
import traceback
# Define the callback response function. In this case it will prompt the user using the console to respond.
def callback(question, responses):
# Print out the expected responses
for resp in responses:
print("[%i] %s" + (resp[1], resp[0]))
# Prompt the user to respond
val = int(input("%s - %s: " % (question[1], question[0])))
# Return their response. Currently only returning the value, but could also return a note (for questions) and the name of the response
return val, "", ""
# Establish a connection to a Workflow database
conn = arcpy.wmx.Connect(r'c:\test\Workflow.jtc')
# Get a Job for Execution
job = conn.getJob(77601)
try:
# Execute the current Step in the Job - a LaunchArcmap step without Proceed to Next enabled
result = job.executeStep(callback=callback)
# A Launch ArcMap step will not finish automatically it will be complete after the user indicates it is.
if not result.finished:
t = input("Please press any key and hit enter when finished step")
# Finish the step and Mark as Complete
result.finishStep(callback=callback)
job.markStepAsComplete(callback=callback)
# Run the next step in the workflow
result = job.executeStep(callback=callback)
print("Executing a 2nd step returned %i" % result.returnCode)
# Mark the step as complete
job.markStepAsComplete(callback=callback)
except wmx.WorkflowExecutionStepError as e:
print("Step failed to execute:")
print("-"*60)
traceback.print_exc()
getAttachments ()
Return Value
Data Type | Explanation |
Attachment | The attachments associated with the job are returned as a list of Attachment objects. |
The attachments provide a way to add information to the job. The following types of attachments can be added to a job:
- Embedded—The file is stored in the Workflow Manager (Classic) database.
- Linked—The link to the file path is stored in the Workflow Manager (Classic) database.
- URL—The URL link is stored in the database.
The following script gets the attachments associated with the job and prints the names of linked attachments.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Get the list attachments associated with the job
attachments = job.getAttachments()
# Print the names of Linked file attachments associated with the job
for attach in attachments:
if attach.type == 'Linked':
print(attach.name)
getExtendedPropertyTable (tableName)
Parameter | Explanation | Data Type |
tableName | The fully qualified table name of the extended property table to be returned. | String |
Return Value
Data Type | Explanation |
ExtendedProperty | Returns the extended property table as the ExtendedProperty object. |
The business-specific information stored as part of the job as extended properties are returned as the ExtendedProperty object.
The following script gets an extended property table associated with the job and prints the name of the cells along with the value.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job with extended properties
job = conn.getJob(99999)
# Get the extended properties table associated with the job
prop_table = job.getExtendedPropertyTable('wmx.extra_properties')
# Iterate over extended properties and print the cell name with values
for (name,value) in prop_table:
print("Cell %s = %s" % (name, value.data))
getHolds ()
Return Value
Data Type | Explanation |
Hold | The job holds returned as a list of Hold objects. |
Holds suspend the job activity for an indefinite amount of time until it is released. A hold may be applied to a job for reasons including the following:
- Insufficient funding
- Technical problems
- Missing data
- Lack of resources
The following example prints the names of Active Holds on the job.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Print the Active Holds on the job
jobHolds = job.getHolds()
for hold in jobHolds:
if hold.active == True:
print("Active Hold = %s" % hold.type)
getPendingDays (consider_hold)
Parameter | Explanation | Data Type |
consider_hold | Flag to determine whether to consider the holds when calculating the number of pending days. | Boolean |
Return Value
Data Type | Explanation |
Integer | Returns the number of days the job has been pending. |
Pending days refers to the number of days the job has been worked on or the number of days the job has been pending before being completed. The start date used for the calculation is either the Start Date if it was set or the Created Date otherwise. The end date for the calculation is either the current date or the End Date if the job is closed.
The following script returns the number of pending days, both when considering and not considering holds in the calculation.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Get pending days for job while considering days on hold
pendingwithholds = job.getPendingDays(True)
print("The number of days pending for job when considering days on hold: " + str(pendingwithholds))
# Get pending days for job while ignoring days on hold
pendingwithoutholds = job.getPendingDays(False)
print("The number of days pending for job when ignoring days on hold: " + str(pendingwithholds))
getWorkflow (jobID)
Parameter | Explanation | Data Type |
jobID | The ID of the job. | Integer |
Return Value
Data Type | Explanation |
Object | Returns the workflow as a Workflow object. |
Provides an easy way to retrieve a job's workflow.
Get the workflow of a job from the Workflow Manager (Classic) database.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Job
job = conn.getJob(99999)
# Access a the job's workflow
workflow = job.getWorkflow()
# Print the name of the workflow
print(workflow.name)
listExtendedProperties ()
Return Value
Data Type | Explanation |
String | List of fully qualified names of all extended property and linked property tables associated with the job. |
The names of tables that store business-specific information with the job as extended properties and linked properties can be retrieved.
The following script lists the fully qualified name of all the extended properties and linked property tables associated with the job.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job with extended properties
job = conn.getJob(99999)
# List all the extended property tables and linked property tables associated with the job
job.listExtendedProperties()
logActivity (activity_type, {message})
Parameter | Explanation | Data Type |
activity_type | The ID or the name of an ActivityType. | String |
message | The custom message to be appended to the existing message in the ActivityType. | String |
The Job history contains a log of everything that has happened throughout the life of the job. Each of the items in the log are time stamped with the time of entry and stamped with the current user at that time. A message is also stored along with the record, explaining what happened at that point in time.
The following example logs a custom activity with a message to an existing job.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Change the assignment of the job to Editors group
job.assignedTo = "Editors"
# Log an activity for the reassignment of the job
job.logActivity('AssignJob', 'Job assigned to Editors group.')
markStepAsComplete ({step_id}, {callback})
Parameter | Explanation | Data Type |
step_id | The ID of the step to be marked as complete. The step ID is optional; if a step ID is not provided, the current step will be executed. | Integer |
callback | The callback argument passes a function that prompts the user for a response based on input from the step type. When marking a question step complete, for example, the callback takes the possible step response options and allows the user to choose the next step. It is also used when the next step in the workflow cannot be determined so a user can select the path to follow. | Function |
Provides a way to mark a step as complete.
The following script marks a step in the workflow complete and provides an example of a callback function that can be used during execution.
import arcpy
import sys
import traceback
# Define the callback response function. In this case it will prompt the user using the console to respond.
def callback(question, responses):
# Print out the expected responses
for resp in responses:
print("[%i] %s" + (resp[1], resp[0]))
# Prompt the user to respond
val = int(input("%s - %s: " % (question[1], question[0])))
# Return their response. Currently only returning the value, but could also return a note (for questions) and the name of the response
return val, "", ""
# Establish a connection to a Workflow database
conn = arcpy.wmx.Connect(r'c:\test\Workflow.jtc')
# Get a Job for Execution
job = conn.getJob(77601)
try:
# Execute the current Step in the Job - a LaunchArcmap step without Proceed to Next enabled
result = job.executeStep(callback=callback)
# A Launch ArcMap step will not finish automatically it will be complete after the user indicates it is.
if not result.finished:
t = input("Please press any key and hit enter when finished step")
# Finish the step and Mark as Complete
result.finishStep(callback=callback)
job.markStepAsComplete(callback=callback)
# Run the next step in the workflow
result = job.executeStep(callback=callback)
print("Executing a 2nd step returned %i" % result.returnCode)
# Mark the step as complete
job.markStepAsComplete(callback=callback)
except wmx.WorkflowExecutionStepError as e:
print("Step failed to execute:")
print("-"*60)
traceback.print_exc()
releaseHold (hold, {comment})
Parameter | Explanation | Data Type |
hold | The hold to be released provided as a Hold object. | Hold |
comment | The comment to be stored as a reason for releasing the hold. | String |
The hold suspends the job activity for an indefinite amount of time until it is released. Once a hold is released, the information about it is never deleted from the system and can be queried.
The following script releases active budget holds associated with the job.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Release the active Budget Holds on the job
jobHolds = job.getHolds()
for hold in jobHolds:
if hold.active == True and hold.type == 'Budget Hold':
job.releaseHold(x, comment='Budget has been approved. The job work can resume')
retrieveAttachment (attachment_id, destination_location)
Parameter | Explanation | Data Type |
attachment_id | The ID of the attachment to be retrieved. | Integer |
destination_location | The folder location where the attachment will be stored. A name for the file to be saved with or without the file extension can also be provided. If no name is provided, the attachment is saved with the default name stored with the job. | String |
The attachments provide a way to add information to the job. The following types of attachments can be retrieved from a job:
- Embedded—The file is stored in the Workflow Manager (Classic) database.
- Linked—The link to the file path is stored in the Workflow Manager (Classic) database. It can be retrieved only if you have access to the file path.
The following script retrieves job attachments to a folder location.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Get the list attachments associated with the job
attachments = job.getAttachments()
# Print the names of Linked file attachments associated with the job
for attach in attachments:
if attach.type == 'Linked':
print(attach.name)
retrieveJobMap (destination_location)
Parameter | Explanation | Data Type |
destination_location | The folder location where the job map will be stored. A name for the map to be saved can also be provided. If no name is provided the job map is saved with the default naming scheme defined for the job map. | String |
The job map has the layers used for editing required as part of the job.
The following script retrieves the job to a disk location.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Retrieve the job map and save to C:\Test
job.retrieveJobMap(destination_location=r'C:\Test')
save ()
The following script saves an updated job assignment.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Update and save the job assignment
job.assignedTo = 'user0000'
job.save()
sendNotification (notification_type)
Parameter | Explanation | Data Type |
notification_type | The name of the notification type template to be used to send the email notification associated with the job. | String |
Email notification can be triggered during the life cycle of a job to provide information about an event related to the job. Examples of sending notifications include the following:
- Job assigned or reassigned
- Job created
- Job closed
The following example reassigns a job and sends an email notification about it.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Reassign the job to a user
job.assignedTo='amiller'
# Send an email notification for the job assignment
job.sendNotification(notification_type='JobAssigned')
setAOI (aoi)
Parameter | Explanation | Data Type |
aoi | The AOI polygon to be assigned to the job. | Geometry |
Define's an area of interest for a job. To get a job's area of interest polygon, use the Get Job AOI tool.
The following script defines a polygon geometry and sets it as the job's area of interest.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Create polygon geometry
coordList = [[-105.0, 39.0], [-100.0, 39.0], [-100.0, 35.0], [-105.0, 35.0]]
array = arcpy.Array([arcpy.Point(x, y) for x, y in coordList])
aoi = arcpy.Polygon(array)
# Set the job's Area of interest to the polygon geometry
job.setAOI(aoi)
job.save()
setDataWorkspace (data_workspace_id)
Parameter | Explanation | Data Type |
data_workspace_id | The GUID of the data workspace to be made active for the job. | String |
Set the data workspace for a job. To get a job's data workspace, use the Get Job Data Workspace tool.
The following script sets a data workspace for a job.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = connect.getjob(99999)
# Set the job's data workspace to a workspace GUID
job.setDataWorkspace("{7887F5C8-CACD-4ADD-88E9-8B37E25C7FF6}")
setLOI (loi)
Parameter | Explanation | Data Type |
loi | The point or polygon to be assigned as the location of interest for the job. | Geometry |
Defines the location of interest for a job. To get a job's location of interest, use the Get Job AOItool.
The following script includes sample code to define a single point or multipoint geometry and set it as the job's location of interest.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# 1. Set the job's location of interest to single point geometry
# Create single point geometry
point = arcpy.Point(-119.5,35.9)
loi_1 = arcpy.PointGeometry(point)
job.setLOI(loi_1)
job.save()
# 2. Set the job's location of interest to multipoint geometry
job = conn.getJob(10000)
# Create multipoint geometry
coordList = [[-105.0, 39.0], [-100.0, 39.0], [-100.0, 35.0], [-105.0, 35.0]]
array = arcpy.Array([arcpy.Point(x, y) for x, y in coordList])
loi_2 = arcpy.Multipoint(array)
job.setLOI(loi_2)
job.save()
setStepAsCurrent (step_id)
Parameter | Explanation | Data Type |
step_id | The ID of the step to be set as the current step. | Integer |
Provides a way to set a step in the workflow as the current active step.
The following script sets a step in the workflow as current.
import arcpy
# Establish a connection to a Workflow database
conn = arcpy.wmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Set a step as current in the Job
job.setStepAsCurrent(2315)
storeJobMap (source_location)
Parameter | Explanation | Data Type |
source_location | The file path that has the map to be stored in the Workflow Manager (Classic) database. | String |
The job map has the layers used for editing required as part of the job.
The following script saves the job map in the Workflow Manager (Classic) database.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\test\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Store the job map in Workflow database
job.storeJobMap(source_location=r'C:\Test\JobMap_17.mxd')
Code sample
The following script updates the assignment of a job and checks that a spatial data version exists by using the job's properties.
import arcpy
import arcpywmx
# Establish a connection to a Workflow database
conn = arcpywmx.Connect(r'c:\sample\Workflow.jtc')
# Access a Workflow Job
job = conn.getJob(99999)
# Update the job assignment
job.assignedTo = 'user0000'
job.assignedType = 'user'
job.save()
# Reload the job
job = job.conn.getJob(99999)
# Check a version exists for the job and get the version name
if job.version == True:
jobversion = job.versionName
print("The job's data workspace is " + jobversion)