I am using a python toolbox in ArcGIS 10.2.2 and want a drop down list of all the versions for the person reconciling to choose from. (And I do not want to include dbo.DEFAULT and DS.Draft). But this list is populated right after a script is run to create the editor's version and if the Python Toolbox isn't refreshed manually in ArcMap, then this newest version doesn't show up in the list.
I looked at updateParameters, but either I was writing it incorrectly or it doesn't work because the user isn't actually changing a parameter that triggers it.
Regardless, I want to refresh the list at the time the script is run.
Can I use updateParameters or do a reload or something else snazzy that will make the list repopulate?
The other thing is I could switch the order of the parameters and having the user type their initials first which would then be a user action that could trigger the updateParmaters, but not sure this is the issue and seems convoluted.
import sys, arcpy, os
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "EGDB Data Steward Version"
self.alias = ""
# List of tool classes associated with this toolbox
self.tools = [Prep]
class Prep(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "Prepare for Reconcile and Post"
self.description = "Create grandfather version of editor for DS"
self.canRunInBackground = False
def getParameterInfo(self):
#Define parameter definitions
params = []
# First parameter
param0 = arcpy.Parameter(
displayName="Editor's Version Name",
name="editor_full_versionname",
datatype="GPString",
parameterType="Required",
direction="Input")
param0.filter.type = "ValueList"
param0.filter.list = [v.name for v in arcpy.da.ListVersions(r"\\inpyosegis05\DatabaseConnectionFiles\DataStewardsOnly\YOSEGIS_VectorYOSE_DS.sde")
if v.name not in ["dbo.DEFAULT", "DS.Draft"]] #Take DEFAULT and Draft off the drop-down list as choices.
# Second parameter
param1 = arcpy.Parameter(
displayName="Data Steward's Initials",
name="DS_initials",
datatype="GPString",
parameterType="Required",
direction="Input")
params = [param0, param1]
return params
def isLicensed(self):
"""Set whether tool is licensed to execute."""
return True
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
param0 = arcpy.Parameter(
displayName="Editor's Version Name",
name="editor_full_versionname",
datatype="GPString",
parameterType="Required",
direction="Input")
param0.filter.type = "ValueList"
param0.filter.list = [v.name for v in arcpy.da.ListVersions(r"\\inpyosegis05\DatabaseConnectionFiles\DataStewardsOnly\YOSEGIS_VectorYOSE_DS.sde")
if v.name not in ["dbo.DEFAULT", "DS.Draft"]] #Take DEFAULT and Draft off the drop-down list as choices.
return
Best Answer
Try the following: