Problem
Mapped Field does not get filled with content from source Shapefile
Situation
I do have a shapefile containing the following columns
FID | Shape | OID_ | Title |
This Shapefile needs to be converted into an existing FeatureClass (with different columns) located inside the fgdb named "ExistingFeatureClass" containing the following columns
OBJECTID | Shape | OID_ | Name |
So the main goal is to convert and fill the "Name" field with its content from "Title" located in the Shapefile.
The below code ALWAYS result into "<Null>" for the "Name" column
var Environments = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true);
var ToolPath = "Append";
var ShapefilePath = "D:\\PathToShapefile\\shapefile.shp";
var FieldMappings = "OID_ \"OID_\" true true false 4 Long 0 0,First,#,D:\\PathToShapefile\\shapefile.shp,OID_,-1,-1;Name \"Name\" true true false 254 Text 0 0,First,#,D:\\PathToShapefile\\shapefile.shp,Title,0,254";
var Parameters = Geoprocessing.MakeValueArray(ShapeFilePath, "ExistingFeatureClass", "NO_TEST", FieldMappings);
await Geoprocessing.ExecuteToolAsync(ToolPath, Parameters, Environments);
While running the code with indentical Parameters using the Dialog (see below) all fields are correctly mapped and only a "Run" is pending for the success
Result = await Geoprocessing.OpenToolDialogAsync(ToolPath, Parameters, Environments);
Any ideas on how to resolve this? Is this a BUG?
Product Information
ArcGIS Pro 2.8.1
using Esri.ArcGISPro.Extensions 2.8.0.29751
I used the following snippet with different schemas (I attached my sample ArcGIS Pro project file):
protected override async void OnClick()
{
try
{
var environments = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true);
var toolPath = "management.Append";
var shapefilePath = @"C:\Users\wolf2125\Documents\ArcGIS\Projects\GPTestAppendTool\ShapeFile\base_state.shp";
var shapefileName = System.IO.Path.GetFileNameWithoutExtension(shapefilePath);
var destintationTable = "BaseState";
var fields = new string[] {
$@"AREA ""AREA"" true false false 8 Double 0 0,First,#,{shapefilePath},AREA,-1,-1",
$@"PERIMETER ""PERIMETER"" true false false 8 Double 0 0,First,#,{shapefilePath},PERIMETER,-1,-1",
$@"BASEMAP_ ""BASEMAP_"" true false false 8 Double 0 0,First,#,{shapefilePath},BASEMAP_,-1,-1",
$@"BASEMAP_ID ""BASEMAP_ID"" true false false 8 Double 0 0,First,#,{shapefilePath},BASEMAP_ID,-1,-1",
$@"Test ""TYPE"" true false false 10 Text 0 0,First,#,{shapefileName},TYPE,0,10" };
var fieldMap = string.Join(";", fields);
var Parameters = Geoprocessing.MakeValueArray(shapefileName, destintationTable, "NO_TEST", fieldMap, "", "");
var gpResult = await Geoprocessing.ExecuteToolAsync(toolPath, Parameters, environments);
Geoprocessing.ShowMessageBox(gpResult.Messages, "GP Messages", gpResult.IsFailed ? GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);
}
catch (Exception ex)
{
MessageBox.Show($@"Error: {ex}");
}
}
Actually I just noticed that I had changed the alias name for the "Test" column in the destination table from "Type" to "Test" but I forgot to make the change in the code snippet. However, i seems that the alias name doesn't matter for this tool.
And what exaclty is the difference (compared to mine?)
When I played around with my sample to find the difference I was not able to get the 'mapped' field populated anymore. I passed the sample on to the GeoProcessing project engineer, i really can't see anything wrong with the code. Also, I think the GP tool should report a warning or error if the 'mapped' field cannot be populated. I will let you know if we find the cause of this issue.
Thanks for you patience and reporting this issue.
Could you please share your data (at least schema)? Or, you can try Wolf's way:
"AREA ""AREA"" true false false 8 Double 0 0,First,#,{shapefilePath},AREA,-1,-1"
Create a variable named shapefilePath and the path of your data to it. Then try and let us know. You can email me at nahmed@esri.com
Could you please share your data? We'd like to try with your data.