bmillerdot

Defining parameters in a Python toolbox for "FieldMapping"

Discussion created by bmillerdot on Feb 15, 2013
Latest reply on Mar 6, 2014 by bmillerdot
How do you add FieldMapping to a Python toolbox?

Here is the webpage for Defining parameters in a Python toolbox.
   --- Defining parameters in a Python toolbox ---
   http://resources.arcgis.com/en/help/main/10.1/index.html#/Defining_parameters_in_a_Python_toolbox/001500000028000000/

Below is how ESRI has documented the parameter for "GEFeatureLayer"
Note: I had to type this as "FeatureLayer" to make it work.

def getParameterInfo(self):
    param0 = arcpy.Parameter(
        displayName="Input Features",
        name="in_features",
        datatype="GPFeatureLayer",
        parameterType="Required",
        direction="Input")


Now I've tried using the same structure to create a parameter for "FieldMapping" which is documented on the following webpage:
   ---- "Defining parameter data types in a Python toolbox" ---
   http://resources.arcgis.com/en/help/main/10.1/index.html#/Defining_parameter_data_types_in_a_Python_toolbox/001500000035000000/

def getParameterInfo(self):
    param0 = arcpy.Parameter(
        displayName="Field Mapping",
        name="in_mapping",
        datatype="GPFieldMapping",
        parameterType="Required",
        direction="Input")

This just gives me a text box. I've also tried: "FieldMapping", "FieldMappings", and a few others. Nothing works.
Even if I have the correct datatype it's not clear how to assign the field mapping to the parameter.

        fms = arcpy.FieldMappings()

I would think it should be something like the ValueList but I cannot find any documentation on this.

Outcomes