Hi,
I am struggling to get this snippet to work:
https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Editing#edit-operation-modify-multiple-features
// at Heading: Edit Operation Modify multiple features
Problem #1 is:
My code below works, loads 421 OIDs but does not execute because modifyFeatures.IsEmpty is TRUE.
The existing date attribute is shown as day-month-year when I look at the attribute table in ArcPro 3.0.2
Problem #2 is:
I am currently selecting on OID to debug this code, but I need to select features with a specific DATE_LASD.
The following WhereClause fails with 'An invalid SQL statement was used.'
(I have tried '-' instead of '/' and also MM-DD-YYYY)
//selq.WhereClause = "DATE_LASD = '20/04/2022'"; // This format is what is shown in Attribute Table
Can anyone spot my deliberate error?
Thank in advance,
Zoltan
public static void setDateLASD()
{
//from: https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Editing#edit-operation-modify-multiple-features
// at Heading: Edit Operation Modify multiple features
// First deactivate OnRowChanged
var selq = new QueryFilter();
//selq.WhereClause = "DATE_LASD = '20/04/2022'"; // This is s what is shown in Attribute Table
selq.WhereClause = "OBJECTID > 7";
IEnumerable<FeatureLayer> layers = MapView.Active.Map.GetLayersAsFlattenedList().Where(
layer => layer is FeatureLayer).Select(x => (FeatureLayer)x);
foreach (var dset in layers)
{
if ((dset.Name.EndsWith("_Point")) ||
(dset.Name.EndsWith("_Line")) ||
(dset.Name.EndsWith("_Polygon")))
{
QueuedTask.Run(() =>
{
var oidSet = new List<long>();
using (var selset = dset.Search(selq))
{
while (selset.MoveNext())
{
using (var record = selset.Current)
{
oidSet.Add(record.GetObjectID());
}
}
}
//create and execute the edit operation
var modifyFeatures = new EditOperation();
modifyFeatures.Name = "Modify LASD";
modifyFeatures.ShowProgressor = true;
var multipleFeaturesInsp = new Inspector();
multipleFeaturesInsp.AllowEditing = true;
multipleFeaturesInsp.Load(dset, oidSet);
multipleFeaturesInsp["DATE_LASD"] = "21/08/2022";
modifyFeatures.Modify(multipleFeaturesInsp);
if (!modifyFeatures.IsEmpty)
{
var result = modifyFeatures.ExecuteAsync(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
}
});
}
}
// Now reactivate OnRowChanged
}