bulk copy of field values from one source to the other
hi guys..
In a Geocortex workflow I'm trying to find an easy way to copy the contents of a souce feature's field contents to a new feature(s) that has been created via a cut, or a union for example..
I basically would like the original fields and values from the source feature to carry over to the new feature(s) created.. before I delete the original feature...
I can see there is an activity called AddRangeToCollection<T> where I've mucked around with using AddRangeToCollection<Field>
where the Input Collection would be the new FeatureSet created ie. newFeatureSet.Fields
and the Items passed in would be the existing selected featureSet.Fields
but I've gotten nowhere with this..
any quick ideas on how to go about this. Currently I'm extracting most field values manually one at a time using an assign statement
eg..
obsCreateDate = fsCapturedGeom.first().attributes("OBS_CREATEDATE")
obsComments = fsCapturedGeom.first().attributes("COMMENTS").toString
obsType = fsCapturedGeom.first().attributes("FIRE_OBS_TYPE_PY").toString
obsIncName = fsCapturedGeom.first().attributes("INCIDENT_NAME").toString
which is working, but painful, as I have to check for null values on the extract (setting the variables as Nullable(of ..), and then the subsequent population of the fields in the newly created feature, again - painful
if we can somehow get the attribute values from the base source to the new features in one hit that would save a LOT of mucking around!
When performing a Cut for example it will obviously take the field names across from the source feature to the two new features created, but not the values that have previously been set and these cannot be lost. ie. Incident number, name, other user or workflow defined field values...
I hope that makes sense :)
cheers guys as always
0
-
You can do something like
g = new Graphic
g.attributes("OBJECTID") = fsCapturedGeom.first().attributes("OBJECTID")
g.attributes("COMMENTS") = fsCapturedGeom.first().attributes("COMMENTS")
g.attributes("FIRE_OBS_TYPE_PY") = fsCapturedGeom.first().attributes("FIRE_OBS_TYPE_PY")
Add this graphic to a new collection (List(of graphic) and use this collection as input for an Update Features activity.0 -
You can do something like
g = new Graphic
g.attributes("OBJECTID") = fsCapturedGeom.first().attributes("OBJECTID")
g.attributes("COMMENTS") = fsCapturedGeom.first().attributes("COMMENTS")
g.attributes("FIRE_OBS_TYPE_PY") = fsCapturedGeom.first().attributes("FIRE_OBS_TYPE_PY")
Add this graphic to a new collection (List(of graphic) and use this collection as input for an Update Features activity.0 -
thanks Nico,
I'll give this a go, but I'm still concerned about how it handles Null values. I still suspect that the UpdateFeatures won't like updating from a collection with Nulls in it.0 -
Nico, I owe you a beer or two!
worked like a charm. I actually made it easier to loop through all fields..
copiedGraphic = fsCapturedGeom.features(0)
for each key in copiedGraphic.attributes.keys
g.attributes(key) = copiedgraphic.attributes(key)
thanks again!0 -
@Gareth do you have a code snip for your loop I could see? I really like this but struggling to get the syntax correct.
I have a few editing tools and its so painful to add all the attributes one by one. This loop can help me a lot.
0 -
I also found this thread as I have been fighting nulls/nothing in populating a Form...been a painful journey. 0 -
Dylan,
PM me at gareth.finney@delwp.vic.gov.au and I can send you the workflow to take a look at. I can't attach it here unfortunately.
cheers
GF0
Please sign in to leave a comment.
Comments
7 comments