Iterate Fields (ModelBuilder)

Summary

Iterates fields in a table.

Learn how Iterate Fields works in ModelBuilder

Usage

  • This tool is intended for use in ModelBuilder, not in Python scripting.

  • The Data Type and Wildcard parameters can be used as filters to limit the fields to iterate.

  • If the Field Names parameter is not defined, the tool will iterate fields that honor the filters, if specified.

  • Duplicate fields in the Field Names parameter will be ignored when the tool executes.

  • This tool has two outputs, Value and Count, that can be used as inline variables (for example, %Value%) in other tools. The Value output is a field type and can be used with other tools that accept a field type value. The Count output is the total number of fields the tool iterates.

  • Geometry fields are not listed in the Data Type parameter but are accessible using the Field Names parameter.

  • If a field is not listed in the Field Names parameter, the Value output will use the first field from the table. If fields are listed in the Field Names parameter, the Value output will use the first field from the Field Names parameter. In both cases, if the first field is the geometry field, it will be skipped.

  • Save tables in edit mode to update fields in the Field Names parameter.

  • This tool accepts inputs with joined tables. Joined tables will generate the field names that honor the Maintain fully qualified field names environment.

  • This tool accepts inputs from a database connection.

  • A message will appear next to the Field Names parameter when any of the following occur:

    • A field does not exist in a table.
    • A field does not match a specified Data Type filter.
    • A field does not match a specified Wildcard filter.
    These messages will appear as warnings on the Iterate Fields tool dialog box and as errors on the Field Names variable dialog box.

Syntax

arcpy.mb.IterateFields(in_table, {field_type}, {wildcard}, {input_fields})
ParameterExplanationData Type
in_table

The input table with fields to be iterated.

Table View; Raster Layer; Mosaic Layer
field_type
[field_type,...]
(Optional)

Specifies the field type used to filter the fields. If a field type is not specified, all fields of the supported field types will be iterated.

  • BLOBBLOB fields will be iterated.
  • DATEDate fields will be iterated.
  • DOUBLEDouble fields will be iterated.
  • FLOATFloat fields will be iterated.
  • GUIDGUID fields will be iterated.
  • LONGLong integer fields will be iterated.
  • RASTERRaster fields will be iterated.
  • SHORTShort integer fields will be iterated.
  • TEXTText fields will be iterated.
String
wildcard
(Optional)

Limits the fields that will be iterated. The wildcard works on both field names and field aliases and is a combination of * and other characters. For example, this parameter can be used to restrict iteration of input field names or field aliases starting with a certain character or word (for example, A* or Ari* or Land*, and so on). An asterisk is equivalent to searching for all the fields. If a wildcard is not specified, all inputs will be returned.

String
input_fields
[input_fields,...]
(Optional)

The list of fields that will be iterated.

Field

Derived Output

NameExplanationData Type
output_field

The field returned by each iteration.

Field
output_count

The total number of fields for all iterations.

Long

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes