Setting default values in Value Tables (script tools)

04-13-2022 06:11 PM
Labels (2)
Regular Contributor

Pretty much what it says on the tin. 

How can I set default values for Value Tables in my script tool parameters?

Either having it as a default when the tool is opened, or a contingent value (i.e. if you pick on value in Column 1, column 2 will automatically be populated)?

Value Tables are more difficult to work with than I'd hoped.


0 Kudos
2 Replies
MVP Esteemed Contributor

Did you see the examples in the help topic?

ValueTable—ArcGIS Pro | Documentation

... sort of retired...
0 Kudos
Regular Contributor

Yes, I reviewed the Value Table help page , as well as multiple pages on script tool parameters, including the Parameter object's help page

I was able to get default to show up by pasting them into the normal default field in the script tool parameter page, using the format:

Col1A [space] Col2A; Col1B [space] Col2B

The column values are separated by spaces, and the rows are separated by semicolons. You will have to place any values that have spaces in them ("Maria's Pizzeria") in quotes.


However, I would like to set these in the Validation page to make setting them easier to read.

I've tried using self.params[N].values== [[Col1A, Col2A], [Col1B, Col2B]] (read: a list of lists, as hinted at in the parameter help page for value tables) under both initializeParameters(self) and updateParameters(self) with no luck.

Under updateParameters, I was predicating it on self.params[N].altered, and while that worked for other things, it did not work for this one.

What is a clean way to set the defaults of a value table in the validation page of a script tool?

0 Kudos