<?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 Re: Field mappings data type parameter in Geoprocessing Tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1329847#M68676</link>
    <description>&lt;P&gt;Also looking for an answer to this, what's the right path, validation or in the properties?&lt;/P&gt;</description>
    <pubDate>Mon, 18 Sep 2023 20:42:47 GMT</pubDate>
    <dc:creator>RossVolkwein1</dc:creator>
    <dc:date>2023-09-18T20:42:47Z</dc:date>
    <item>
      <title>Field mappings data type parameter in Geoprocessing Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/142552#M11090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a script that I'm trying to migrate over to an ArcGIS pro toolbox as a script tool. The script is using the fieldmappings python object however I would like to use the Field Mappings Datatype within the script tool's parameters to control the field mapping. ( I have substituted the fieldmappings python object for the one within the tool's parameters.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue I'm having is that only the input tables show up within the field mapping section for the tool. None of the fields show up for the output table. Just to reiterate, It does not give me the option to choose which fields in table 1 match&amp;nbsp; fields in table 2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have not been able to find any good documentation on how to correctly use the Field Mapping datatype. Does anyone have a working example of how to set this up correctly?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2019 17:47:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/142552#M11090</guid>
      <dc:creator>deleted-user-NvcfpBOWaKwr</dc:creator>
      <dc:date>2019-10-28T17:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Field mappings data type parameter in Geoprocessing Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/142553#M11091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fields and Field mapping need to specify a dependency in order to see the field lists.&lt;/P&gt;&lt;P&gt;A pic might be best&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/469585_field_dependency.png" /&gt;&lt;/P&gt;&lt;P&gt;In this example, Input features are a parameter as are the fields to sort.&amp;nbsp; In order to get the list of fields to choose from in the tool, a Dependency for the sort fields had to be the input features (feature class)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2019 18:08:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/142553#M11091</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-10-28T18:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Field mappings data type parameter in Geoprocessing Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/142554#M11092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for getting back to me Dan. I have the dependencies set. So whats happening, I've included pictures, the fields for the output table are showing up as they should be. However in an attempt to reconcile sources by clicking the source tab you should be able to see the field from the other table to allow you to match. It's only showing the output fields again.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji image-1 jive-image j-img-original" src="/legacyfs/online/469564_tool gui.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should look like this (From the Append Tool)&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji jive-image image-2 j-img-original" src="https://community.esri.com/legacyfs/online/469598_append.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are my parameters for the script tool&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji jive-image image-3 j-img-original" src="https://community.esri.com/legacyfs/online/469599_parameters.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't seem to figure out how to set the correct table for use in the source tab.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2019 19:03:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/142554#M11092</guid>
      <dc:creator>deleted-user-NvcfpBOWaKwr</dc:creator>
      <dc:date>2019-10-28T19:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Field mappings data type parameter in Geoprocessing Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/142555#M11093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;line 5 in the last dialog. output field, derived.&amp;nbsp; If memory serves derived parameters don't show&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/setting-script-tool-parameters.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/setting-script-tool-parameters.htm"&gt;Setting script tool parameters—Geoprocessing and Python | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2019 20:36:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/142555#M11093</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-10-28T20:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Field mappings data type parameter in Geoprocessing Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1324651#M68509</link>
      <description>&lt;P&gt;Still no solution to this? Do you need to use the validation to set the initial parameter value.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 08:07:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1324651#M68509</guid>
      <dc:creator>vtey_esriau</dc:creator>
      <dc:date>2023-09-01T08:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Field mappings data type parameter in Geoprocessing Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1329847#M68676</link>
      <description>&lt;P&gt;Also looking for an answer to this, what's the right path, validation or in the properties?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 20:42:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1329847#M68676</guid>
      <dc:creator>RossVolkwein1</dc:creator>
      <dc:date>2023-09-18T20:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: Field mappings data type parameter in Geoprocessing Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1331524#M68738</link>
      <description>&lt;P&gt;I'm also finding it difficult to find a way of listing the source fields in the field map parameter. The target fields are fairly straight forward but not clear how to be able to do the actual mapping.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 16:33:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1331524#M68738</guid>
      <dc:creator>MattHowe</dc:creator>
      <dc:date>2023-09-22T16:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Field mappings data type parameter in Geoprocessing Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1331720#M68741</link>
      <description>&lt;P&gt;Sharing what works for me.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def getConfig(self):
        mapping = {
                "fieldMap": {
                    "xxx":{
                        "Name": "xxx",
                        "transformation":None #Transformation isn't used for testing
                    },
                    "xxx":{
                        "Name":"xxx",
                        "transformation":"addHahaToTest"
                    },
                    "xxx":{
                        "Name":"xxx",
                        "transformation":None
                    }
                }
            }
        return mapping
    

    def updateParameters(self):
        # Modify parameter values and properties.
        # This gets called each time a parameter is modified, before 
        # standard validation.
        #See https://gis.stackexchange.com/questions/324510/creating-field-mapping-parameter-in-arcpy-script for listfield example if required.
        #inputTable = self.params[1].value #default how pro does it
        #self.params[2].value = str('Empty')  #default how pro does it
        #self.params[2].value.addTable(inputTable)  #default how pro does it
        if self.params[0].altered:
            inputTable = self.params[0].value
            fms_param = self.params[1]
          
            fms_param.value = str('Empty')
            
            fms_param.value.addTable(inputTable) #this is the only way i can get to populate the drop down
            initialFieldCount = fms_param.value.fieldCount
            self.params[2].value = initialFieldCount
           
            inputField_names = [field.name for field in arcpy.ListFields(inputTable)] #list comprehension
                        
            config = self.getConfig()
            
            firstKey = None
            for key,value in config["fieldMap"].items():        
                
                blockNumber_fm = arcpy.FieldMap()
                default_input_field = value['Name'] if value['Name'] in inputField_names else inputField_names[0]
                blockNumber_fm.addInputField(inputTable, default_input_field)            
                blockNumber_name = blockNumber_fm.outputField
                blockNumber_name.name = key #this can be set to anything.
                blockNumber_fm.outputField = blockNumber_name                                            
                fms_param.value.addFieldMap(blockNumber_fm)
                                
                if firstKey == None:
                    firstKey = key              
            for i in range(initialFieldCount):
                fms_param.value.removeFieldMap(0)  
            
        return&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 22 Sep 2023 22:46:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1331720#M68741</guid>
      <dc:creator>vtey_esriau</dc:creator>
      <dc:date>2023-09-22T22:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Field mappings data type parameter in Geoprocessing Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1362904#M69455</link>
      <description>&lt;P&gt;Is this solved? Facing the same problem in ArcMap append tool too.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2023 01:18:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mappings-data-type-parameter-in/m-p/1362904#M69455</guid>
      <dc:creator>Rohanrajan</dc:creator>
      <dc:date>2023-12-20T01:18:53Z</dc:date>
    </item>
  </channel>
</rss>

