Field mappings data type parameter in Geoprocessing Tool

166
3
10-28-2019 10:47 AM
deleted-user-NvcfpBOWaKwr
Occasional Contributor

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.)

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  fields in table 2. 

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? 

0 Kudos
3 Replies
DanPatterson_Retired
MVP Esteemed Contributor

Fields and Field mapping need to specify a dependency in order to see the field lists.

A pic might be best

In this example, Input features are a parameter as are the fields to sort.  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)

0 Kudos
deleted-user-NvcfpBOWaKwr
Occasional Contributor

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. 

It should look like this (From the Append Tool)

Here are my parameters for the script tool

I can't seem to figure out how to set the correct table for use in the source tab. 

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

line 5 in the last dialog. output field, derived.  If memory serves derived parameters don't show

Setting script tool parameters—Geoprocessing and Python | ArcGIS Desktop 

0 Kudos