Working with the Update FeatureLayer using applyEdits() sample code I have added a button in attributeArea div to select an image file to add (update) the point that is currently selected.
I've updated the featureform.on submit process (below - lines 6 and 17) but it seems to be throwing an error that "When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true"
I am not quite sure how to exactly handle attachments in this situation.
featureForm.on("submit", () => {
if (editFeature) {
// Grab updated attributes from the form.
const updated = featureForm.getValues();
const attachmentForm = document.getElementById("photo");
// Loop through updated attributes and assign
// the updated values to feature attributes.
Object.keys(updated).forEach((name) => {
editFeature.attributes[name] = updated[name];
});
// Setup the applyEdits parameter with updates.
const edits = {
updateFeatures: [editFeature],
addAttachments: [attachmentForm]
};
console.log(edits);
applyEditsToIncidents(edits);
document.getElementById("viewDiv").style.cursor = "auto";
}
});