Hi,
I am saving graphics in feature service and I would like to add/update Attribute values to feature was just added
Below is the code I am able to Save graphics to Feature layer Service.
function createfreehandline (graphic)
{
var freeHLayer = this.map.getLayer('freeHLayer'); // Layer added in map Feature Service layer
freeHLayer.applyEdits([graphic], null, null).then(function (adds, updates, deletes) {
console.log('success', adds);
}, function (err) {
console.log(err);
});
}
For Example, with above code new feature with ObjectId added, now I want to update attribute value in Field name "JOBNO"
How can I update the attribute value of feature that was just added ?
Solved! Go to Solution.
Hi Ken,
Thanks for your reply.
After adding below line I was getting error " Cannot set property 'JOBNO' of undefined"
graphic.attributes["JOBNO"] = newAttribute;
So, I Created new object then add attributes to object and set to graphic. Below code worked for me
var SaveAttribute = new Object(); SaveAttribute.JOBNO= newAttribute; graphic.attributes = SaveAttribute; freeHLayer.applyEdits([graphic], null, null).then(function (adds, updates, deletes) { console.log('success', adds); }, function (err) { console.log(err); });
Thanks,
Before you call applyEdits, change the attribute of the graphic to the value newAttribute
graphic.attributes["JOBNO"] = newAttribute;
freeHLayer.applyEdits([graphic], null, null).then(function (adds, updates, deletes) {
Hi Ken,
Thanks for your reply.
After adding below line I was getting error " Cannot set property 'JOBNO' of undefined"
graphic.attributes["JOBNO"] = newAttribute;
So, I Created new object then add attributes to object and set to graphic. Below code worked for me
var SaveAttribute = new Object(); SaveAttribute.JOBNO= newAttribute; graphic.attributes = SaveAttribute; freeHLayer.applyEdits([graphic], null, null).then(function (adds, updates, deletes) { console.log('success', adds); }, function (err) { console.log(err); });
Thanks,