0

I'm updating a feature in ESR-Leaflet from a feature layer based on a call to a function. What I'm having trouble with is submitting this change to the feature service.

Currently I: Get the feature based on it's ObjectID; Reach into the feature.properties and change "SystemStatus"; Attempt to submit updateFeatures (and fail).

Code, and error below.

function ChangeStatus(objID){
    var retireFeatureID = hotspots.getFeature(objID);
    retireFeatureID.feature.properties["SystemStatus"] = "Deleted";
    hotspots.updateFeature(retireFeatureID, function (err, response) {
        if (err) {
             console.log(err);
             return;
        }   
            console.log(response);
    });
    //hotspots.updateFeature(retireFeatureID);
    console.log("Updated the status of feature: " + objID);
}

The error I'm receiving is:

{code: 400, message: "Cannot perform operation. Invalid operation parameters.", details: Array(2)} code: 400 details: (2) ["'features' parameter is invalid", "Object reference not set to an instance of an object."] message: "Cannot perform operation. Invalid operation parameters."

I'm not sure what could be causing my issue here. Suggestions welcome.

0

The answer was in the updateFeature line. I needed to include '.feature' because otherwise it was sending the entire object, which is not what was expected.

function WriteLog(objID){
    var retireFeatureID = hotspots.getFeature(objID);
    retireFeatureID.feature.properties["SystemStatus"] = "Deleted";
    hotspots.updateFeature(retireFeatureID.feature, function (err, response) {
        if (err) {
            console.log(err);
            return "error";
        }   
            console.log(response);
            return "ok";
    });
    console.log("Updated the status of feature: " + objID);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.