I'm trying to easily create a data expression that adds an attribute to each feature in a data set, but I'm getting stuck on how to add an attribute to an existing feature without creating a feature from scratch, including all pre-existing attributes.
I get an execution error: "key not found - attributes.'
In short, do I have to create a brand new feature and manually reference each attribute I need, or is there an easy way to simply add an attribute to an existing feature.
var portal = Portal('https://www.arcgis.com/');
var layer = FeatureSetByPortalItem(portal, itemid)
var features=[];
for (var i in layer) {
var newvalue = some logic here
i['attributes']['newattribute'] = newvalue
Push(features,i)
}
return {
geometryType:'',
features:features
}