GUIDs or Global Unique Identifiers are a great way to ensure that you have unique primary keys in your database, especially when you have a multiple "offline" users updating and syncing their data back to your central repository. Funny, but this is exactly what ArcPad is doing, but ArcPad doesn't handle GUIDs very well. Specifically if you want to use scripting to update said GUID fields.Several data models are moving to GUIDs as primary keys such as APDM and PODS.Specifically I would like to group a bunch of point features (Control Points) by a GUID (LineID). I have incorrectly assumed that it would be an easy task of setting the Field.Value when the FORM onok event is fired. I have used that method to set text fields and date fields for a long time now. However GUID fields throw a "script error 800004005" related to not being able to access the data when you do. Oddly, it does save the new value.onok="Call SetVals( ThisEvent.Object )"
Sub SetVals(obj)
obj.Fields("COLLECTEDDATE").Value = now()
obj.Fields("LINE_GUID").Value = UserProperties("LineGUID")
End Sub
So I backtracked and tried using the RecordSet fired with the "onfeatureadded" event.onfeatureadded="'Call UpdateVals( ThisEvent )"
Sub UpdateVals(this)
dim currentRS
set currentRS = this.Object.Records
currentRS.Bookmark = this.Bookmark
currentRS.Fields("COLLECTEDDATE").Value = now()
currentRS.Fields("LINE_GUID").Value = UserProperties("LineGUID")
this.Object.Records.Update
End Sub
This method throws a "Error 800A01AD - ActiveX component can't create object" error. The script dies and the Records.Update never happens so the value is not saved to the database.Anybody got a different approach? I can use text fields, but that will require more processing in the office to maintain compatibility with APDM or PODS. I currently support 3-15 field crews working on a couple hundred pipelines a week and want (need) to automate the field collection process as much as possible.Having the field monkeys manage the LineID/Primary Key does NOT work, don't even suggest it.