<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Attribute outputField not supported in this instance of FieldMap in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1033621#M60245</link>
    <description>&lt;P&gt;Hi. I'm having difficulty with field mapping in arcpy - it keeps throwing this error:&amp;nbsp;"The attribute 'outputField' is not supported on this instance of FieldMap." and I'm not sure why. It never manages to get past the first instance, but if I take that part out it complains that streamorder isn't declared. I swear I copied this almost word for word from the documentation, and I'm really not sure why it's failing.&lt;/P&gt;&lt;P&gt;Not sure if this is the right place for this question, so if there's somewhere else I should ask please let me know!&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;PRE&gt;#setting workspaces and paths&lt;BR /&gt;arcpy.env.workspace = path.join(workspace, outgdb, geodataset)&lt;BR /&gt;canadafcs = arcpy.ListFeatureClasses()&lt;BR /&gt;print("Geodataset and feature classes found.")&lt;BR /&gt;&lt;BR /&gt;#separating feature classes by whether they abbreviate the field name or not&lt;BR /&gt;#creating blank lists&lt;BR /&gt;fullwords = []&lt;BR /&gt;abbrev = []&lt;BR /&gt;&lt;BR /&gt;#running a for loop to get through the feature classes&lt;BR /&gt;for fc in canadafcs:&lt;BR /&gt;  fieldlist = arcpy.ListFields(fc)&lt;BR /&gt;  if "STREAM_ORDER" in fieldlist:&lt;BR /&gt;    fullwords.append(fc)&lt;BR /&gt;  elif "STRMRDR" in fieldlist:&lt;BR /&gt;    abbrev.append(fc)&lt;BR /&gt;&lt;BR /&gt;print("Feature classes separated by field name format.")&lt;BR /&gt;&lt;BR /&gt;#setting up field mappings:&lt;BR /&gt;fm_order = arcpy.FieldMap()&lt;BR /&gt;fieldmapping = arcpy.FieldMappings()&lt;BR /&gt;fm_order.mergeRule = "First"&lt;BR /&gt;print("Field mapping parameters set.")&lt;BR /&gt;&lt;BR /&gt;#if the fc uses full words, add the fc and "STREAM_ORDER" as an input field&lt;BR /&gt;for fc in fullwords:&lt;BR /&gt;  fm_order.addInputField(fc, "STREAM_ORDER")&lt;BR /&gt;&lt;BR /&gt;#if the fc uses abbreviated words, add the fc and "STRMRDR" as an input field&lt;BR /&gt;for fc in abbrev:&lt;BR /&gt;  fm_order.addInputField(fc, "STRMRDR")&lt;BR /&gt;&lt;BR /&gt;print("Input fields added.")&lt;BR /&gt;&lt;BR /&gt;#this is where it throws the error - trying to add streamorder as an output field&lt;BR /&gt;streamorder = fm_order.outputField&lt;BR /&gt;streamorder.name = "Stream_Order"&lt;BR /&gt;fm_order.outputField = streamorder&lt;BR /&gt;&lt;BR /&gt;fieldmapping.addFieldMap(fm_order)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Mar 2021 22:17:41 GMT</pubDate>
    <dc:creator>SP_WWU</dc:creator>
    <dc:date>2021-03-05T22:17:41Z</dc:date>
    <item>
      <title>Attribute outputField not supported in this instance of FieldMap</title>
      <link>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1033621#M60245</link>
      <description>&lt;P&gt;Hi. I'm having difficulty with field mapping in arcpy - it keeps throwing this error:&amp;nbsp;"The attribute 'outputField' is not supported on this instance of FieldMap." and I'm not sure why. It never manages to get past the first instance, but if I take that part out it complains that streamorder isn't declared. I swear I copied this almost word for word from the documentation, and I'm really not sure why it's failing.&lt;/P&gt;&lt;P&gt;Not sure if this is the right place for this question, so if there's somewhere else I should ask please let me know!&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;PRE&gt;#setting workspaces and paths&lt;BR /&gt;arcpy.env.workspace = path.join(workspace, outgdb, geodataset)&lt;BR /&gt;canadafcs = arcpy.ListFeatureClasses()&lt;BR /&gt;print("Geodataset and feature classes found.")&lt;BR /&gt;&lt;BR /&gt;#separating feature classes by whether they abbreviate the field name or not&lt;BR /&gt;#creating blank lists&lt;BR /&gt;fullwords = []&lt;BR /&gt;abbrev = []&lt;BR /&gt;&lt;BR /&gt;#running a for loop to get through the feature classes&lt;BR /&gt;for fc in canadafcs:&lt;BR /&gt;  fieldlist = arcpy.ListFields(fc)&lt;BR /&gt;  if "STREAM_ORDER" in fieldlist:&lt;BR /&gt;    fullwords.append(fc)&lt;BR /&gt;  elif "STRMRDR" in fieldlist:&lt;BR /&gt;    abbrev.append(fc)&lt;BR /&gt;&lt;BR /&gt;print("Feature classes separated by field name format.")&lt;BR /&gt;&lt;BR /&gt;#setting up field mappings:&lt;BR /&gt;fm_order = arcpy.FieldMap()&lt;BR /&gt;fieldmapping = arcpy.FieldMappings()&lt;BR /&gt;fm_order.mergeRule = "First"&lt;BR /&gt;print("Field mapping parameters set.")&lt;BR /&gt;&lt;BR /&gt;#if the fc uses full words, add the fc and "STREAM_ORDER" as an input field&lt;BR /&gt;for fc in fullwords:&lt;BR /&gt;  fm_order.addInputField(fc, "STREAM_ORDER")&lt;BR /&gt;&lt;BR /&gt;#if the fc uses abbreviated words, add the fc and "STRMRDR" as an input field&lt;BR /&gt;for fc in abbrev:&lt;BR /&gt;  fm_order.addInputField(fc, "STRMRDR")&lt;BR /&gt;&lt;BR /&gt;print("Input fields added.")&lt;BR /&gt;&lt;BR /&gt;#this is where it throws the error - trying to add streamorder as an output field&lt;BR /&gt;streamorder = fm_order.outputField&lt;BR /&gt;streamorder.name = "Stream_Order"&lt;BR /&gt;fm_order.outputField = streamorder&lt;BR /&gt;&lt;BR /&gt;fieldmapping.addFieldMap(fm_order)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 22:17:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1033621#M60245</guid>
      <dc:creator>SP_WWU</dc:creator>
      <dc:date>2021-03-05T22:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute outputField not supported in this instance of FieldMap</title>
      <link>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1033725#M60265</link>
      <description>&lt;P&gt;Not sure of this will help you, but its another example of fieldmapping.&amp;nbsp; I created a function a while ago to assist in feildmappings that are the same name.&amp;nbsp; This takes the target FC, joinfc, and a list of fields that you want to keep from the joinfc.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def fieldMapping(targetfc=None, joinfc=None, keepfields=None):
    '''
    Function to assist in making joins by mapping all the fields in the target fc and
    including a list of fields that is wanted within the join dataset..
    targetfc: featureclass that you want to output
    joinc: featureclass that you want to join to the target fc
    keepfields: a list of fields that you want to keep from the joinfc.
    '''
    trglist = [i.name for i in arcpy.ListFields(targetfc)]

    # List of fields to keep during Join operation
    fldMap = arcpy.FieldMappings()

    # Creating field maps for the two files
    fldMap.addTable(targetfc)
    fldMap.addTable(joinfc)
    
    # add the list of fields from the targetfc to the keepfield list 
    keepfields.extend(trglist)

    # Removing unwanted fields from the fieldmap
    for field in fldMap.fields:
        if field.name not in keepfields:
            fldMap.removeFieldMap(fldMap.findFieldMapIndex(field.name))

    return fldMap&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have fields that have different names, then after this function you can add them individually by&lt;/P&gt;&lt;LI-CODE lang="python"&gt;firstfldmap = fieldMapping(targetfc, joinfc, keepfieldslist)

secondfldmap = arcpy.FieldMap()
secondfldmap.addInputField(targetfc, "ACCOUNT")
secondfldmap.addInputField(joinfc, "accountno")
secondfldmap_name = secondfldmap.outputField
secondfldmap_name.name = "ACCOUNT"
secondfldmap.outputField = secondfldmap_name

# then add that field map to the other fieldmap that you returned from the function
firstfldmap.addFieldMap(secondfldmap)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Mar 2021 19:07:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1033725#M60265</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-06T19:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute outputField not supported in this instance of FieldMap</title>
      <link>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1036278#M60387</link>
      <description>&lt;P&gt;Thanks Jeff! I ended up not using field mapping after all - I worked around it by renaming the fields in all my different datasets the same thing so they'd map together automatically. Still not sure what went wrong with my program, but it works now.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Mar 2021 18:34:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1036278#M60387</guid>
      <dc:creator>SP_WWU</dc:creator>
      <dc:date>2021-03-13T18:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute outputField not supported in this instance of FieldMap</title>
      <link>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1165968#M64356</link>
      <description>&lt;P&gt;Is this any Different in ArcGIS Pro? I used this approach in ArcMap but in transitioning to ArcGIS Pro (2.9), I get an error&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\arcobjects\_base.py", line 90, in _get
    return convertArcObjectToPythonObject(getattr(self._arc_object, attr_name))
AttributeError: FieldMap: Get attribute outputField does not exist

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\...", line 223, in execute
    address_eid = fm_tf_eid.outputField
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\arcobjects\_base.py", line 96, in _get
    (attr_name, self.__class__.__name__))
AttributeError: The attribute 'outputField' is not supported on this instance of FieldMap.&lt;/LI-CODE&gt;&lt;P&gt;This is from the geoprocessing window in ArcGIS Pro running my script in a Python toolbox.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 23:31:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1165968#M64356</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-04-19T23:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute outputField not supported in this instance of FieldMap</title>
      <link>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1568401#M73338</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Replying to this old discussion because I had the same issue and didn't see any good documentation online about it.&amp;nbsp; I figured out that the "outputField not supported in this instance of FieldMap" error occurs when you try to set the &lt;STRONG&gt;outputField&lt;/STRONG&gt; property before you define the input fields using the &lt;STRONG&gt;.addInputField()&lt;/STRONG&gt; method.&amp;nbsp; It seems that you have to define input fields on the FieldMap object before it will allow you to set up the output field properties.&amp;nbsp; So you need to do&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fm.addInputField(layer,field)&lt;/LI-CODE&gt;&lt;P&gt;before you set the output field.&lt;/P&gt;&lt;P&gt;Another thing to be aware of that tripped me up is that the FieldMap object will not allow you to set properties of the &lt;STRONG&gt;outputField&lt;/STRONG&gt; directly.&amp;nbsp; If you try something like&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fm.outputField.name = "NewField"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;it will not stick and it will just overwrite whatever properties you give it with the default mapping based on the input fields.&amp;nbsp; Instead you need to create a copy of the&amp;nbsp;&lt;STRONG&gt;outputField&lt;/STRONG&gt; property, update the properties of the copy, and then replace the entire&amp;nbsp;&lt;STRONG&gt;outputField&lt;/STRONG&gt; with the copy.&amp;nbsp; This is shown in the arcpy documentation, but it's a little unclear why it's necessary.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;outf = fm.outputField
outf.name = "NewField"
# other properties
fm.outputField = outf&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 13:45:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attribute-outputfield-not-supported-in-this/m-p/1568401#M73338</guid>
      <dc:creator>NH_MapMan</dc:creator>
      <dc:date>2024-12-13T13:45:39Z</dc:date>
    </item>
  </channel>
</rss>

