I am working on a tool validator and am having an issue where the layer.longName is only returning layer.name. In the code snippet below, the first set of appends to my list should be adding the longName of each layer that is already in a multivalue field. However, when I check what values are being added to my list it is only the short names.
I have attached images that show the output and the values of retList after each step.
def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
if self.params[0].value:
searchString = self.params[0].value
mxd = arcpy.mapping.MapDocument("CURRENT")
retList = []
if self.params[1].values:
for value in self.params[1].values:
if type(value) is type(arcpy.mapping.ListLayers(mxd, "*")[0]):
retList.append(value.longName)
win32api.MessageBox(0, "retList: " + str(retList))
for df in arcpy.mapping.ListDataFrames(mxd):
for lyr in arcpy.mapping.ListLayers(mxd, "*" + searchString + "*", df):
if lyr.longName not in retList:
retList.append(lyr.longName)
win32api.MessageBox(0, "setting values to: " + str(retList))
self.params[1].values = retList
return