# Name: SetNextTask_sample.py
# Description: This script will take the next task with a status of 1 and set it as the next task for the parent job
# Import System Modules
import arcpy
# Check Out Extensions
arcpy.CheckOutExtension('Foundation')
arcpy.CheckOutExtension('JTX')
# Setting the environment
arcpy.env.overwriteOutput = True
# Setting Local Variables
job_id = 2072
input_database_connection = r'C:\Data\Workflows\Testing.jtc'
# Calling the Set Next Task to update the TOPO_TASK_GROUP_PROPERTIES table and to set the next job
arcpy.topographic.SetNextTask(job_id, input_database_connection)
# Getting all messages, warnings, and errors from the tool run and printing the results back to the user
messages = arcpy.GetMessages(0)
warnings = arcpy.GetMessages(1)
errors = arcpy.GetMessages(2)
arcpy.AddMessage('Tool Messages: {}\nTool Warnings: {}\nTool Errors{}\n'.format(messages, warnings, errors))
# Check In Extensions
arcpy.CheckInExtension('Foundation')
arcpy.CheckInExtension('JTX')