i have python tool box with definition query tool, the tool activate definition query on multiple layers
In running into hard wall when trying to display only the fields that mutual to the different layers
When try to display the list of the fields the dialog shows only few fields and not all
I'm testing it on 2 similar layers with 90 fields. Turned off 3 in one layer and the dialog show only 4 instead of 87
With no filter i get all the fields in the first layer
how to let the user see only the mutual
list of fileds?
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."""
if parameters[0].values:
all_layers_field_list = []
for layer in parameters[0].values:
field_names = [f.name for f in arcpy.da.Describe(layer.name)["fields"]]
all_layers_field_list.append(field_names)
list_fields = list(set(all_layers_field_list[0]).intersection(*all_layers_field_list[1:]))
parameters[1].filter.list = list_fields
if parameters[1].value:
field_values =list(set([row[0] for row in arcpy.da.SearchCursor(parameters[0].values[0], [parameters[1].valueAsText],f"{parameters[1].valueAsText} IS NOT NULL")]))
parameters[2].filter.list = field_values
return