Select to view content in your preferred language

Create New Feature, Populate a field based of ObjectID value

885
2
06-05-2013 03:06 PM
NathalieNeagle
Regular Contributor
I have an applicaiton Silverlight and when a users creates a new feature, I want to automatically populate a field called "FeatureID" with the value that was assigned in the ObjectID field (by ArcGIS).  I'm struggling with how to do this and I'm wondering if someone could give me a push or insight. 

I would love to do it on the back-end in the database schema (like how you do it for a domain and you have a default domain in your GDB but I don't think this is possilble so I'm looking to do it in code).



Thanks
Nathalie
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
Did you try to subscribe to Editor.EditCompleted event and in the Handler, test if action is 'Add' and update your attribute there?
0 Kudos
NathalieNeagle
Regular Contributor
Dom,

Thanks for the reply.  I fell off this task for awhile but now I'm back on and need to finish up.  After I listen for the Editor.EditCompleted event I then need to update the features attribute.

I was looking for answer on the rest api page.  Before I check this post I posted a question about the work-flow

http://forums.arcgis.com/threads/89806-My-own-attribute-editing-function

Here it is so you don't have to link over

I've been looking at the Apply Edits (Operation) example in the help document (REST API).

I can take an example there and add a feature and update a feature -

http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/

I can add and update for the html. I do this by going to the end point

http://sampleserver3.arcgisonline.co...r/0/applyEdits

and dropping the appropriate code in the entry areas.

If I switch to JSON I can also get the JSON to work


Here's where I'm no stuck

How do I push an update from my code. Do you write everything in the url string
EXAMPLE - http://sampleserver3.arcgisonline.co...Edits/****HTML OR JSON **TO DO WORK***

Or do you somehow give the url in your code
http://sampleserver3.arcgisonline.co...r/0/applyEdits
and then place your html or JSON in the appropriate input boxes -- "ADD, UPDATES, DELETES"

Will you show me an example of this - I'm writing in Silverlight but if the example was in JS or FLEX I'm sure I could figure it out.

I would like to push with JSON

An example would be great to show me, I should be able to study that example and learn from that and do it on my own.



Right now I have this:

void EditorWidget_EditCompleted(object sender, Editor.EditEventArgs e)
  {
    if (e.Action == Editor.EditAction.Add)
    {
    foreach (var edit in e.Edits)
     {
       if (edit.Layer is FeatureLayer)
        {
         if (e.Action == Editor.EditAction.Add)
          {
             .....udate feature layer with JSON update here
           }
         }
     }
    }
}


Not totally sure if that is correct but....

THanks
Nathallie.
0 Kudos