My dropdown list is populating correctly. The issue is that if the selection changes while the tool is open, clicking the refresh arrows does not call updateParameters() and does not update the dropdown. Below is a screenshot, and an example .pyt script.
import arcpy
class Toolbox(object):
def __init__(self):
self.label = "Toolbox"
self.alias = "toolbox"
self.tools = [Tool]
class Tool(object):
def __init__(self):
self.label = "Tool"
self.description = ""
self.canRunInBackground = False
def getParameterInfo(self):
# Feauture Layer
fc = arcpy.Parameter(
displayName="Define Feature Layer",
name="fc",
datatype="GPFeatureLayer",
parameterType="Required",
direction="Input")
# Drop down of OIDs from feature layer
oids = arcpy.Parameter(
displayName="Select OID",
name="oids",
datatype="GPString",
parameterType="Required",
direction="Input")
params = [fc,oids]
return params
def updateParameters(self, parameters):
#if feature layer is defined
if parameters[0].altered and not parameters[0].hasBeenValidated:
#get list of OIDs
oidfield = arcpy.Describe(parameters[0].value).OIDFieldName
oidlist = [row[0] for row in arcpy.da.SearchCursor(parameters[0].value, oidfield)]
#and populate the dropdown
parameters[1].filter.list = oidlist
parameters[1].value = oidlist[0]
return
def execute(self, parameters, messages):
return