1

I want to create a script tool in a regular ArcMap toolbox (not python tool box if possible) and have a multi-value field input parameter that allows you to sort the input fields, just like the "Attributes of Interest" input in the "Similarity Search" GP Tool in the built-in Spatial Stats Tools toolbox. I can get a regular multi-value field input, but that only gives me all of the fields (that meet the filter requirements) in a pre-populated list, with check-boxes. What my script tool needs however, is to get a list of field names from the user in a user specified order.

The "Similarity Search" GP tool has 2 inputs at the end of that tool that do exactly what I am wanting, and I've compared their settings with mine and I see nothing different, but they have a sortable multi-field input. Additionally, if I copy that script tool into my own toolbox and delete the entire validation code section (code on the Validation tab of the script tool properties dialog), when I re-open that tool it still has the sortable multi-field input desired, so it does not appear to be validation code specific. However, if I change any of the parameter display names in that script tool's properties, it suddenly reverts to the regular multi-field select box.

How can I get my script tool to replicate the Similarity Search GP tool's multi-field input?

I'd ideally like:

Desired Multivalue Field Input Parameter

Instead of:

Multivalue Field Input Parameter I can get to work

2

So, after a decent bit of researching, testing, and troubleshooting... I was not able to figure out any way to get a multi-value field type input parameter for a script tool in ArcMap/Catalog to allow the fields to be added in a user specified order and/or sorted as desired. However, I did finally discover an annoyingly simple work-around, so I'm sharing in case others find it useful. So, here are the steps.

  1. Create the script tool with the default multi-value field input that can't be sorted.
  2. Create a model with model builder (I recommend putting the model in the same toolbox as the script tool and setting it to use relative paths).
  3. Then, in model builder, go to Insert > Create Variable. In the dialog box select the "Field" data type, and make sure to check the box for "Multivalue". Click OK. If you open this variable, it should have the desired style that allows you to manually add fields in a desired order and sort them.
  4. Add the script tool to the model and use the "connect" tool in model builder to add the newly created model-builder variable as the input to the script tool's multi-value field type input parameter.
  5. Next right click on the script tool and make a variable from any of the other parameters the script tool may have.
  6. Finally rename any of these variables as desired and right click all of them and mark them as Model Parameters. Save and close.

Essentially, for some reason the multi-value field type input parameter used for a script tool and the multi-value field type input parameter used for a model variable are 2 completely different input styles, with the model builder version allowing the desired functionality. So you have to create the variable in model builder and use that as the script's input (no, just adding the script tool to model builder and making a variable from the script tool's parameter will not solve it). Basically you make a model builder wrapper for your script tool, and you can get a sortable multi-value field type input parameter.

Or, if you are able to, you can switch to ArcGIS Pro, which allows this functionality by default.

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.