Very simply I am trying to enrich a feature on creation by adding a createdAt datetime. However when I add this additional attribute, the feature does not get created.
I am learning how to add this attribute so that in future I can filter features by date and/or create heatmaps.
Code is very simple:
//feature layer setup
const featureLayer = new FeatureLayer({
geometryType: "polygon",
title: "Test Feature Layer",
source: [],
objectIdField: "UniqueId",
spatialReference: {
wkid: 102100
},
fields: [{
name: "id",
alias: "UniqueId",
type: "guid"
}, {
name: "description",
alias: "Description",
type: "string"
}, {
name: "createdDate",
alias: "CreatedDate",
type: "date"
}],
outFields: ["*"],
popupTemplate: popupTemplateDetails,
});
// adding feature
var polygon = this.addPolygonGraphic({ id: e.id, description: e.description, createdDate: new Date(2019, 4, 25) }, rings);
this.areaFeatureLayer.applyEdits({ addFeatures: polygonFeatures });
function addPolygonGraphic(attributes: { [key: string]: any }, rings: any) {
var polygon = new Polygon({
rings: rings,
spatialReference: {
wkid: 102100
}
});
var graphic = new Graphic({
geometry: polygon,
attributes: attributes
});
return graphic;
}
What am I missing here?