Editing attributes in Editor widget needs an event before applying edit. I have columns that their values depend on another column. I tried Form Constraints and Field calculations in Arcade but they do not work for all scenarios.
If there is a new event like "before-apply-edit", it will help in validating all columns before posting.
Regars,
Markos
Hi Markos,
Totally agree — a before-apply-edit event would be super useful for validating or adjusting values before the Editor widget submits the edits.
I’ve run into the same issue when one field depends on another. Arcade constraints and calculations are great for some use cases, but they don’t always work when the logic gets more complex.
If you’re using Developer Edition, a workaround is to hook into the form submit logic manually, validate the fields, then call applyEdits() yourself. But yeah, having a native event like before-apply-edit would make things much cleaner.
Might be worth submitting this as an enhancement request to Esri — I know others would benefit too.
Cheers,
Venkat
I was looking for a before-edits event a few weeks ago. @JoelBennett came up with a good workaround on this post.
That's not a bad idea...you could extend that workaround to include validation like so:
var featureLayer = new FeatureLayer({
//etc
});
featureLayer.originalApplyEdits = featureLayer.applyEdits;
featureLayer.applyEdits = function(edits, options) {
var errorMessage = null;
//validate the values in the edits object; if validation fails, set a string value to the errorMessage variable, for example:
/*
if (edits.addFeatures[0].attributes.name === "")
errorMessage = "Name - value required";
*/
if (typeof errorMessage == "string")
return Promise.reject(new Error(errorMessage));
else
return this.originalApplyEdits.apply(this, arguments);
};