Hello,
I’m creating a custom edit widget that will populate some values on the new feature from a geoprocessing service.
The plan is to capture the before-apply-edits event of the feature layer, execute the service, update the attributes and then open the attribute editor. I know this will work except the attribute editor doesn’t wait for the service to respond. I thought I needed to implement dojo.deferred but I guess I'm confused as to it's purpose because that’s not working. In the most general terms, how do I stop the thread while waiting for the service to respond?
Some code:
on(featureLayer, 'before-apply-edits', lang.hitch(this, this.onBeforeApplyEdits))
onBeforeApplyEdits: function (evt) {
if (evt.adds != null) {
this._newFeature = evt.adds[0];
var features = [];
features.push(this._newFeature);
var featureSet = new FeatureSet();
featureSet.features = features;
var params = {"Query_Point": featureSet};
var gp = new Geoprocessor("http://avalanche:6080/arcgis/rest/services/GetMileposts/GPServer/Get%20Mileposts");
var def = gp.execute(params);
def.then(lang.hitch(this, function (idResults) {
this._newFeature.attributes["MP"] = idResults[0].value;
}),function(err){
});
}
}What am I doing wrong?
Thanks!
Jill