Hi,
I am still getting to grips with editing functionality on featurelayers so I hope someone can help:
I have a graphic created at runtime that has some attributes attached to it. I want to publish that graphic as a feature to a feature layer in the operational layers of my viewer. This works brilliantly.
The issue is that my users may not wish to publish the graphic to the database but still need to generate it and consequently it's attributes as it may be saved away as a file and recalled at a later time (siilar to how Robert Scheitlins eDraw widget does it!).
But if publish option is selected, I need them to add some further detail (like dates and a comment) which will then be used to filter the feature layer when selecting from it later. This needs to be added as an extra couple of attributes which then also need to be written to the feature class.
If I add extra attributes before I apply the edits and add the feature, it doesnt save at all. I get no exceptions and it looks as though it worked, but the data is not in the feature class. I have no idea why!
Here is my code that works fine:
Code:
private function publishWDADetail():void
{
//need to be able to add the values from the controls to the attributes of the graphic in order to save information that
//is searchable by date to the feature class!
//this works but doesnt have form attributes in it
//publish the selected graphic by creating it as a feature and applying it as an edit to the feature layer for published traces
publishingFeatureLayer = map.getLayer("Traces") as FeatureLayer;
publishingFeatureLayer.applyEdits([ publishedTraceGraphic ], null, null);
This code below should work (i think!) - but doesn't. When I use the variables window to explore the attributes of the graphic object I can see the attributes have been added as expected!
Code:
addAttributesFromControls()
publishingFeatureLayer = map.getLayer("Traces") as FeatureLayer;
PublishingFeatureLayer.applyEdits([ publishedTraceGraphic ], null, null);
//here is the code I am using to add extra attributes to the publishedTraceGraphic Graphic object from my attribute widget.
private function addAttributesFromControls():void
{
publishedTraceGraphic.attributes["USER_TAG"] = txtUserTag.text;
publishedTraceGraphic.attributes["COMMENT"] = txtComment.text;
publishedTraceGraphic.attributes["TRAINING_AREA_NAME"] = ViewerContainer.getInstance().mapManager.trainingAreaName;
publishedTraceGraphic.attributes["RANGE_STATUS_ID"] = "4";
publishedTraceGraphic.attributes["FIRING_START_DATE"] = getDateTime("DateFrom").toString();
publishedTraceGraphic.attributes["FIRING_END_DATE"] = getDateTime("DateTo").toString();
publishedTraceGraphic.refresh();
}
All ideas welcome! This one is keeping me up at night!