Task does not display all rows of ValueTable

459
4
Jump to solution
11-14-2023 12:22 PM
PhilLarkin1
Occasional Contributor III

I have a Geoprocessing Script Tool that auto-populates parameters via the initalizeParameters function of the ToolValidator class. This works well when the Tool is run from the toolbox. 

Code:

 

def initializeParameters(self):
	# Customize parameter properties. 
	# This gets called when the tool is opened.
	parcels = ['test1','test2']
	valueTable = arcpy.ValueTable(len(parcels))
	valueTable.setColumns(["GPString","GPDouble"])
	for parcel in parcels:
		valueTable.addRow([parcel, None])

	self.params[0].value = valueTable

 

 

Tool Display when open from Toolbox:

PhilLarkin1_0-1699993030715.png

This does not run as expected when using Tasks. Task Display:

PhilLarkin1_1-1699993134611.png

Only the first item in the parcels list is loaded. There are no errors reported. Does anyone have any suggestions or workarounds? I am using Pro 3.1.0.

Thanks

1 Solution

Accepted Solutions
PhilLarkin1
Occasional Contributor III

When making changes to the validation code, specifically modifying the initializeParameters function, you need to reload the Geoprocessing Tool to get code changes recognized. Who Knew. 

If you find yourself in this predicament reload the tool or check/uncheck embed in the Task Designer

View solution in original post

0 Kudos
4 Replies
PhilLarkin1
Occasional Contributor III

I thought that maybe removing the for loop might help. This was substituted using the loadFromString function. It had the same result: the task only displays one of the values. 

 

 valueTable.loadFromString(';'.join([f"'{i}' 'None'" for i in parcels]))

 

0 Kudos
PhilLarkin1
Occasional Contributor III

I have also tried loading different values for the Acres column under the theory that loading None is a problem. ('1' , '1.1', '1.0')

0 Kudos
PhilLarkin1
Occasional Contributor III

Instead of populating the value table i've attempted to set a filter on a column of the VT. This also results in the same issue. The VT is missing when the script tool is run from Tasks. Something is off related to the initalizeParameters in Validation. 

0 Kudos
PhilLarkin1
Occasional Contributor III

When making changes to the validation code, specifically modifying the initializeParameters function, you need to reload the Geoprocessing Tool to get code changes recognized. Who Knew. 

If you find yourself in this predicament reload the tool or check/uncheck embed in the Task Designer

0 Kudos