Hi,
I am trying to hard code values for some fields I am accessing in the Attribute Inspector. Essentially, I would like to set a GIS_Editor and GIS_Edited_Date field(s) equal to the current user (logged in via a asp LoginName).
I am not real sure where this would be done. I have a section in my code that I tried to do this, but it didn't work. Am I even looking in the right place?
Here is my test code:
dojo.connect(attInspector, "onAttributeChange", function (feature, fieldName, newFieldValue) {
//store the updates to apply when the save button is clicked
updateFeature.attributes[fieldName] = newFieldValue;
updateFeature.attributes["GIS_Editor"] = dojo.byId('LoginName').innerHTML;
updateFeature.attributes["GIS_Edited_Date"] = dojo.byId('ServerTime').innerHTML;
});
I would just do a little change on your onAttributeChange handler. like this:
dojo.connect(attInspector, "onAttributeChange", function (feature, fieldName, newFieldValue) {
if (fieldName=="GIS_Editor")
{
updateFeature.attributes["GIS_Editor"] = dojo.byId('LoginName').value;
}
else if (fieldName == "GIS_Edited_Date")
{
updateFeature.attributes["GIS_Edited_Date"] = dojo.byId('ServerTime').value;
}
else
updateFeature.attributes[fieldName] = newFieldValue;
});
For add a feature or upate a field where you use statement featureLayer.applyEdits. do the attribute setting as above before you apply the applyEdits.Hope it works for you.