Select to view content in your preferred language

ArcPad and GUID fields

1713
5
08-15-2011 04:21 PM
RobertMcCann
Deactivated User
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.
Tags (3)
0 Kudos
5 Replies
RobertMcCann
Deactivated User
If you want to stop arcpad from auto populating GUID fields, open a command window (ie right click on a layer and select "show data") and use the following SQL:

ALTER TABLE [tableName]
ALTER COLUMN [GUIDcolumn] DROP DEFAULT


Upon checkout arcpad is setting the default of all GUID columns to "NewID()" which is a stored function in SQL to generate new GUID's.

However, this doesn't fix the errors I'm encountering in the first post.
0 Kudos
RobertMcCann
Deactivated User
Well, ESRI has confirmed that this is not possible 😞  Recommended workaround is to use text fields.
0 Kudos
GarethWalters
Deactivated User
Hi Robert,

Can I clarify a couple of things with your dataset?
Do you have a related table scenario?
Related by a GlobalID and the GUID you are trying to update?
Or a single feature class with a globalID and another column in that which is a GUID?

I also assume that the data is in an AXF.

How about trying updating the rows through the Datasource object, then you can pass SQL queries through. This works well for me.

Cheers,

Gareth
0 Kudos
RobertMcCann
Deactivated User
Hi Robert,

Can I clarify a couple of things with your dataset?
Do you have a related table scenario?
Related by a GlobalID and the GUID you are trying to update?
Or a single feature class with a globalID and another column in that which is a GUID?

I also assume that the data is in an AXF.

How about trying updating the rows through the Datasource object, then you can pass SQL queries through. This works well for me.

Cheers,

Gareth


Thanks for the reply Gareth.

To clarify:

Data is checked out to an AXF from SDE or FileGDB's.  Issues exist using either Database.

Checking out GlobalID fields is apparently not supported with arcpad: "CQ00312796:ArcPad Checkout geoprocessing tool fails for features with relationship class based on a GUID".  ESRI support has not expanded the scope of that bug to include my particular case, however they have replicated it.

I have 3 feature classes.  One feature class has related tables, however I am NOT trying to update the related fields via scripting.  There are no relations between feature classes.

Users will only be collecting point type features (ControlPoints) and I am populated the other features (polylines) via scripting without geometry.  Point feature will have a single column not involved in a relationship that will also be updated via scripting.  Not the best to have application logic trying to maintain referential integrity, but you have to use messy hacks like this with ESRI products...

I have tried using DataSource object as well, but have issues managing the bookmark cursor across the multiple feature classes.  Got an example of how you're doing this?

Again, ESRI has replicated my issues and has replied that "this sort of functionality is not supported".  Whats most annoying is: it sort of is supported, I can get the values to changes, however it throws the error, which I believe to be an issue with type casting in the way arcpad tries to access the GUID field type.

Plugging along using text fields, not as elegant, but functional.
0 Kudos
GarethWalters
Deactivated User
Hi Robert,

The issue with that CQ will be supported in the new release of 10.0.3. In fact there should be a build going up on the ArcPad Beta site this week that you can try.

I would suggest that you have unique DataSource, counters, recordsets and bookmark variables per layer. This way you can keep track of them indivually.

Sign up for the beta if you haven't already and if possible can you upload your project or atleast some of the code?

Cheers,

Gareth
0 Kudos