Hey guys, first time using applyedits so Im a little confused on the process.
I have a graphic that id like to add to a feature layer. so I have the graphic and I am able to add just the graphic to the feature layer. but the user needs to add the attributes themselves otherwise everything is pretty much null. I am trying to set attributes before the apply edits that way a lot of the attributes can be set automatically, but I get an error that says
{code: 500, message: "Unable to complete operation.", details: Array[0], log: undefined, httpCode: 500…}
Code:
map.graphics.on("click", function(evt) { console.log("click graphic"); evt.graphic.setAttributes( {"OBJECTID":2312,"PARCELID":"1231233","STATUS":"RETIRED"});//test values FeatureLayr.applyEdits([evt.graphic],null,null,null,errCallback); }); }); });
If I remove line 3 above (setAttributes) a dialog comes up to enter the attributes, but if I have the set attributes code I get that error. not sure I understand what the error is saying.
Solved! Go to Solution.
Ok, figured it out. it was a scope issue.
placing the setAttributes after the applyedits fixed it, which makes sense. Thanks Ken, figured it out with your tip.
In my application, I'm setting the attributes of the feature with this syntax before I use the applyEdits method. The fields of the feature are "Priority", "Management", and "Criteria"
feature.attributes.Priority = priorityValue; feature.attributes.Management = managementValue; feature.attributes.Criteria = criteriaValue;
Thanks, you're getting me on the right track. But the current graphic only has these fields.
attributes:
Object
OBJECTID:
created_date:
created_user: ""
last_edited_date:
last_edited_user: ""
I noticed when I do setAttributes, they all get removed and the ones I set are the ones that are there.
Ok, figured it out. it was a scope issue.
placing the setAttributes after the applyedits fixed it, which makes sense. Thanks Ken, figured it out with your tip.