Select to view content in your preferred language

Hi I want to create a feature from the Editor widget and when its created i want to apply the value in the back end which needs to updated on the attr

455
1
10-31-2022 04:49 AM
PalaniSwamy
New Contributor
 
0 Kudos
1 Reply
JeffreyWilkerson
Frequent Contributor

Since the Editor widget is creating your feature you can't pass any attributes at creation, you need to set up an event monitor for the layer being edited, and then when that occurs create the attribute for the feature and save it using Apply Edits.

Maybe something like this:

 

 

aLayer.on("apply-edits", function (results) {
    
    if (results.edits.addFeatures) {
        var newObjectId = results.addFeatureResults[0]["objectId"]; 
        console.log("Added new feature with objectID: ", newObjectId);
        var edit = [{"id" : 0, 
            "updates": [
                "attributes": {
                  "OBJECTID": newObjectId,
                  "datetime": 1272210710000,
                  "Somefield": "This is an updated value" 
                } 
            ]
        }]
        var promise = aLayer.applyEdits(edit);
        console.log(promise);
    }
})

 

 

 

 

0 Kudos