I'm sure this is quite simple, but I'm missing something. I want to provide the option to select a field in a model. I have added a field variable, but I don't see any way to provide a layer to populate the fields.
In the tool's properties, I can see this as a parameter, but the 'Dependency' option is unresponsive.
How does one plug a layer into a field variable?
Thank you,
Randy McGregor
Model parameters—ArcGIS Pro | Documentation
Dependency
You can make a parameter dependent on another parameter. The typical use for this is to make one parameter that accepts an attribute field dependent on another parameter that is a feature class or table; the field parameter will include a drop-down list of attribute fields from the dependent parameter.
Which means that you have to provide the featureclass first
Hello Randy
This has got me thinking because, just like you, I can not set the"dependency" up in a model - it is grayed out in the Model Properties dialog ; Parameters tab, just as you report.
I will see if I can make contact with the ModelBuilder team to see why this is and I will report back to this thread.
As a workaround.... how is your Python scripting? The dependency does work in a Python Script tool, for example:
1: Create a Python Script tool in a custom toolbox (Right click a custom toolbox or the project's default toolbox and choose New > Script)
2: Fill in the Name and Label text boxes on the General tab.
3: Click the Parameters tab.
4: Create 2 parameters as shown below:
Notice the data types.
5: For the attribute field parameter scroll until you see the Dependency property.
6: Click in the Dependency property for the Attribute field parameter and select the feature layer parameter name:
This should set up the dependency of the Field parameter to display the attribute fields of the chosen feature layer.
7: Press the OK button on the New Script dialog to create your script tool.
8: Double click the script tool to display the dialog. You should see 2 parameters:
9: Choose the input feature layer (or feature class) and the Choose attribute field parameter should then be populated!
I ask how are your Python skills as you would need to convert you model to a Python script to take advantage of the above. You would need to use arcpy.GetParameterAsText() to pass in the user choices on the dialog into your script.
I hope this helps.... thanks ed
Thank you Ed,
I have quite a bit of experience with Python and have set up dependencies successfully with it. This was my first time trying to set one up with ModelBuilder 🙂