AnsweredAssumed Answered

Update a field

Question asked by miribsystematics-co-il-esridist Employee on Feb 5, 2015
Latest reply on Feb 8, 2015 by miribsystematics-co-il-esridist

Hi everyone,

 

I'm trying to automatically update a date field with Date.now() value using the Edit widget with some changes.

 

What ever I do, it does not update the field.

Can someone tell me what's wrong with my code?

 

this.editor = new Editor(params, this.editDiv);
this.editor.startup();
var feature;
      
var attInspector = this.editor.attributeInspector; 
attInspector.showObjectID = false;
      
var theMap = this.editor.settings.map;
var saveButton = new dijit.form.Button({label:"שלח","class":"saveButton"}); 
dojo.place(saveButton.domNode, attInspector.deleteBtn.domNode, "before"); 

 

saveButton.on("click", function(evt) {
  if (feature == null)
   alert("Pleae enter values");
  else {
   if (feature.attributes["description"] == null) {
      alert("Description field is required");
      return;
   }
  
  feature.attributes["date1"] = Date.now();      
   theMap.infoWindow.hide();
  }
});

attInspector.on("attribute-change", function(evt) {
   feature = evt.feature;
   feature.attributes["date1"] = Date.now();
   feature.getLayer().applyEdits(null, [feature], null);
});

theMap.infoWindow.resize(350, 600);
        this.resize();
      },

 

Thanks a lot,

Miri

Outcomes