Dynamically choosing a field in Model Builder?

4849
8
11-24-2016 03:24 AM
LukeHaskett
New Contributor

Hello,

I'm trying to build a model that can take any feature class loaded in and then have the field names available as a user-selected variable which will then power a bunch of geoprocessing tools. How do I set this up so that I can choose the dataset and then the appropriate field name before pressing run on the model?

Thanks!

Luke

0 Kudos
8 Replies
XanderBakker
Esri Esteemed Contributor

Yes you can, see instructions here: Field filter—Help | ArcGIS for Desktop 

LukeHaskett
New Contributor

Hi Xander,

Thanks for your help. I'm having trouble with it though - doesn't a field filter decide what type of field can be allowed rather than letting you specify actual field names? I want a tool where you specify the dataset that needs buffering and then specify the relevant field name that contains the information that will drive the buffer sql expression. I can't see how to do this using the help page you've posted?

I'd really appreciate your thoughts as it's driving me mad!

Luke

EDIT: I've found a way to do it using the 'Get Field Value' Utility... but this only accepts tables as inputs, not feature classes. How can I extract field values from feature classes?

0 Kudos
XanderBakker
Esri Esteemed Contributor

In fact the Get Field Value—Help | ArcGIS for Desktop  tool (although it mentions "tables" in the help) also allows the use of featureclasses. 

curtvprice
MVP Esteemed Contributor

I've found a way to do it using the 'Get Field Value' Utility... but this only accepts tables as inputs, not feature classes.

This should work with any tool that takes a layer/feature class/table/table view and a field as input if you mark the dataset input and the field input as input parameters, not just Get Field Value.

0 Kudos
LukeHaskett
New Contributor

Hi,

I have the following model set up:

but whenever I try to change the input feature class my model won't run because of the following errors:

How do I set up this tool so that it accepts feature classes? Am I doing something obviously wrong here??

Thanks!

0 Kudos
DanPatterson_Retired
MVP Emeritus

what is the OpenSpace parameter defined as? The only reference I could fine had something to do with cityengine.  The error is saying that that parameter has to be of a particular type and featureclass etc isn't one of them

0 Kudos
LukeHaskett
New Contributor

I seem to have fixed it by using the 'Make Feature Layer' tool as an intermediary - the field value tool is happy with a feature layer, just not a feature class.

0 Kudos
curtvprice
MVP Esteemed Contributor

Select Layer by Attribute requires an input feature layer, if you want to use that tool you need to make a layer from your input in case it is a feature class.

0 Kudos