1

I am trying to create a drop-down list containing all the values from a particular field, that I can use as an input for the Select by Attributes tool in ModelBuilder.

The answer I’ve seen to similar questions is to hard-code the list using the String Variable.

i.e. Right-click in white space > Create Variable… > String > Choose to Model Parameter > Model > Model Properties… > make String filter = Value List > enter values one by one > Then use %String% as an in-line variable in a tool expression.

However, as the field is regularly updated by other people, I don’t want to hard-code any values.

Is there any way that I can perhaps, iterate through a layer (called "Boundary") and collect the values from a given field ([Name] field) as a String or Value(?) that can be used as an in-line variable in another tool, with ModelBuilder (or with Python script)?

The outcome being a drop-down list filled with values from the Boundary layer's [Name] field in the Select by Attributes tool.

1

If you think about it, how many tools do you use that return values from a dataset as a choice? None and probably for good reason. What if your dataset had 1 billion rows? It would need to search all those to be able to know what to list and offer up as choice.

Is this a road you want to go down? Offering up more than a few options will make the user interface slow and eventually unusable.

You can't do this in model builder, you would need to migrate your entire workflow into a python script tool or python toolbox. You need to research the help file on how to use a search cursor to update a Parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.