Original User: sirpinkeeI am trying to make my geoprocessing script update DEVICE and ADDRESS field based on the selection of a LOCATION, so that when a user selects a location (MHA or City), it lists the devices and addresses common to those locations. So far so good, have been able to list either but not both. For example: if a user selects location(City), the device list and address list (which are fields both common to the location layer) are displayed. On the other hand, if the user then decides to change the selection to location(MHA), it doesn't update the list, instead I still have values from the previous list (City). Here is my code in the ToolValidator:
def initializeParameters(self):
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened."""
import arcpy
address = []
device = []
rows = arcpy.SearchCursor(r"Database Connections\Test_GDB_SQL2005.sde\Test_GDB.GISADMIN.MHAedit")
for row in rows:
if row.Device_Typ not in device:
device.append(row.Device_Typ)
if row.Site_Addre not in address:
address.append(row.Site_Addre)
del row, rows
address = sorted(address)
device = sorted(device)
address1 = []
device1 = []
rows = arcpy.SearchCursor(r"Database Connections\Test_GDB_SQL2005.sde\Test_GDB.GISADMIN.Citydbf2")
for row in rows:
if row.Device_Typ not in device1:
device1.append(row.Device_Typ)
if row.Site_Addre not in address1:
address1.append(row.Site_Addre)
del row, rows
address1 = sorted(address1)
device1 = sorted(device1)
self.params[0].filter.list = ["City", "MHA"]
if self.params[0].filter.list == "City":
self.params[1].filter.list = device1
self.params[2].filter.list = address1
else:
self.params[1].filter.list = device
self.params[2].filter.list = address
if self.params[0].filter.list == "MHA":
self.params[1].filter.list = device
self.params[2].filter.list = address
else:
self.params[1].filter.list = device1
self.params[2].filter.list = address1
return
N.B - The first screenshot which has the "City" selected in the Location field is correct but the second screenshot which has the "MHA" selected in the Location field still displays the address list for the "City" whereas the address list that should have been displayed is actually lesser than what is currently being displayed.[ATTACH=CONFIG]16940[/ATTACH][ATTACH=CONFIG]16941[/ATTACH]