I'm not sure why I keep getting this error, "Copy operation failed Edit operation failed. The value type is incompatible with the field type." I checked the value type and field type, and it's the same, both a double value and field type. I'm trying to perform some calculations using the attribute table of a featureClassA, then create a new featureClassB with the output calculations. In the featureClassA, there are numerous of null values in the dataset. I suspect it is related to the null values. What are the common reasons for this error message? I included a shorter version of my script below:
foreach (var FieldID in FieldIDList)
{
//AWC
Process.AggregateValues(input values here));
}
WriteAggregateFields(FieldIDList, outGDB);
});
public async void PopulateAggregateValues(input values here)
{
var mv = MapView.Active;
var newLayer = NewLayerName;
var newLayerPath = outGDB + "\\" + newLayer;
var dict = new Dictionary<string, object>();
//var idList = FieldIDList;
string Field_Low = FieldName + "_Low";
string Field_Rep = FieldName + "_Rep";
string Field_High = FieldName + "_High";
var FinalLyr = mv.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(fl => fl.Name.Contains(newLayer)).FirstOrDefault();
int i = 0;
await QueuedTask.Run(() =>
{
EditOperation edOp = new EditOperation();
using (var rowCursor = AggregateLayer.Search())
{
while (rowCursor.MoveNext())
{
using (var row = rowCursor.Current as Feature)
{
if (LowArea > 0)
{
dict[Field_Low] = FieldList[i].Item1;
}
else
{
dict[Field_Low] = "<Null>";
}
if (RepArea != double.NaN)
{
dict[Field_Rep] = FieldList[i].Item2;
}
else
{
dict[Field_Rep] = "<Null>";
}
if (HighArea > 0)
{
dict[Field_High] = FieldList[i].Item3;
}
else
{
dict[Field_High] = "<Null>";
}
edOp.Modify(FinalLyr, row.GetObjectID(), dict);
i++;
}
}
}
if (!edOp.Execute())
{
MessageBox.Show($@"Copy operation failed {edOp.ErrorMessage}");
return;
}
});
}
}
private void WriteAggregateFields(List<string> FieldIDList, string outGDB)
{
var AggregateLayer = SelectedAggLayer;
var AggregateField = SelectedField;
var newLayerPath = outGDB + "featureClassBName";
//Populate featureClassB fields
Process.PopulateGeomID(outGDB, "NewLayer", AggregateLayer,
AggregateField, FieldIDList);
Process.PopulateAggregateValues(outGDB, "NewLayer", AggregateLayer, AggregateField, FieldList, "FieldName", FieldLowArea, FieldRepArea, FieldHighArea);
}
Thanks for your help!
Hi,
Try to change all places where you use "<Null>" to null