I have a web app builder project that has an editable layer in it. The project ID is being based to the web app through the URL. I can grab this in javascript and use it. What I'd like to do is set the default value for the projectid field that is written by the edit widget when a new record is created.
any pointers on where in the edit widget code I can intercept where the values are written and returned to the feature service?
Solved! Go to Solution.
Alistar,
You can do that by modifying the edit widget _worksAfterCreate function:
_worksAfterCreate: function(AddrPt2) {
// add close button to atiInspector
this._addButtonToInspector();
// resize editPopup
this.editPopup.resize(500, 251);
// update templatePicker for responsive.
this.editor.templatePicker.update();
//Add the autopopulate field value
this.editor.templatePicker.on("selection-change", lang.hitch(this, function() {
var selected = this.editor.templatePicker.getSelected();
if (selected) {
var featureLayer = selected.featureLayer;
on.once(featureLayer, "before-apply-edits", lang.hitch(this, function(evt){
if(evt.adds && evt.adds.length > 0){
if(evt.adds[0].attributes.hasOwnProperty('ADDRESS')){
evt.adds[0].attributes.ADDRESS = AddrPt2;
}
this.editor.attributeInspector.refresh();
}
}));
}
}));
//End add
Alistar,
You can do that by modifying the edit widget _worksAfterCreate function:
_worksAfterCreate: function(AddrPt2) {
// add close button to atiInspector
this._addButtonToInspector();
// resize editPopup
this.editPopup.resize(500, 251);
// update templatePicker for responsive.
this.editor.templatePicker.update();
//Add the autopopulate field value
this.editor.templatePicker.on("selection-change", lang.hitch(this, function() {
var selected = this.editor.templatePicker.getSelected();
if (selected) {
var featureLayer = selected.featureLayer;
on.once(featureLayer, "before-apply-edits", lang.hitch(this, function(evt){
if(evt.adds && evt.adds.length > 0){
if(evt.adds[0].attributes.hasOwnProperty('ADDRESS')){
evt.adds[0].attributes.ADDRESS = AddrPt2;
}
this.editor.attributeInspector.refresh();
}
}));
}
}));
//End add
Hi. I have the same issue. I don’t known where to put this function worksAfterCreate. I need your help.