Select to view content in your preferred language

EditTool Autopopulate Fields

2368
4
02-13-2011 05:48 PM
ShannakaBeveridge
Emerging Contributor
Hi,

Is there a way to autopopulate fields in the attribute editor when creating and editing features? e.g. inserting the current date into a date field.

Cheers,

Shannaka
Tags (2)
0 Kudos
4 Replies
SimonMorgan
Frequent Contributor
Hi,

Is there a way to autopopulate fields in the attribute editor when creating and editing features? e.g. inserting the current date into a date field.

Cheers,

Shannaka


Not sure about how to auto-populate the date field, but with all other fields you could set a default value at the database level OR set a default value on the editing template in the MXD. The flex viewer will respect these default values. To access the editing templates, simply open an edit session in the MXD you published to the server and right click the appropriate layer in the create features window and go to properties.
0 Kudos
JoelShegrud
Deactivated User
I hope there is someone who will correct me, but everyone that I have talked to has said that you have to use code to autopopulate the Date field in FlexViewer. I don't have the experience to help you write the code but possibly someone else who reads this can.
0 Kudos
ShannakaBeveridge
Emerging Contributor
I found that I could autopopulate fields in the Attribute Inspector of the Edit widget using

private function featureLayer_selectionComplete(event:FeatureLayerEvent):void

This works for both adding new features and editing existing features.
0 Kudos
ShannakaBeveridge
Emerging Contributor
For anyone using the method above, you will need to add the following code to update the layer:

var updates:Array = [ feature ];
event.featureLayer.applyEdits(null, updates, null);
0 Kudos