Accessing GlobalID of an AGSGDBFeature object?

7487
8
Jump to solution
08-12-2014 09:49 AM
by Anonymous User
Not applicable

Hello all,

I have just found that I cannot see the GlobalID attribute in an AGSGDBFeature object from a local geodatabase used by an iOS SDK app that I'm working on.  We have two feature classes (A and B).  Features in B have a GUID attribute that stores the GlobalID attribute of a related feature in A.

In the iOS runtime SDK, an AGSGDBFeature from featureclass B will allow me to access the GUID attribute that refers to the GlobalID of a feature in A  (e.g., NSLog(@"A GUID from featureclass B: %@", [feature attributeAsStringForKey:@"A_GUID"]); ).

However, an AGSGDBFeature from featureclass A does not give me access to the GlobalID attribute anywhere.  For example, I have logged-out the complete attributes from a feature in featureclass A (e.g., NSLog(@"All attributes: %@",[[featureA allAttributes] description]); ), and there is a definite absence of the GlobalID attribute.

Is here something I'm doing wrong? Or is there a deliberate reason that we should not have (read-only) access to the global ID attribute?  Perhaps there is there some other way I can get at it?  I can see the globalid in the SQLite geodatabase file...

The main reason I'd want access to the globalid attribute in featureclass A is so that I can use it to populate the corresponding GUID field in featureclass B for related features.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DiveshGoyal
Esri Regular Contributor

Hi, Michael -

You're right, the SDK does not give you access to the GlobalID field. We originally made that field inaccessible because it is something that is managed by the underlying geodatabase model, and we didn't think it would be useful to application developers. But as you described, there valid cases where one needs it to manually establish relationships, or uniquely query features.

The GlobalID field will be accessible in the next release of the SDK.

_

Divesh

View solution in original post

8 Replies
MichaelDavis3
Occasional Contributor III

I think if you want to use the globalID fields you should be managing the relationships and records using ESRI's built in functions like queryRelatedFeaturesWithParameters.  As far as I can tell Global IDs are indeed inaccessible.

That said we've had a lot of trouble using the built in relationships in offline geodatabases... read about our woes here:

GlobalID error when saving edits to offline geodatabase

For now we are maintaining our own relationships and IDs without using GlobalID - it really isn't that much more complicated to just pass in an ID and execute a normal query.  We build our IDs using the device name and a date/time stamp to keep things unique

0 Kudos
by Anonymous User
Not applicable

That would be okay if I was only reading the data.  But I need to create new features in featureclass B that would have a GUID field that stores a GlobalID form a feature in featureclass A.

So how do I assign the value to this attribute in featureclass B if I cannot access the GlobalID of a feature in featureclass A?   Is there a method that does this?  If so, I'm unable to find it in the API reference.

0 Kudos
MichaelDavis3
Occasional Contributor III

In our case we use our own primary key fields to perform this function.  For instance: when creating a new related feature the user clicks an "add" button on a form and a new view is generated... at that time the foreign key attribute linking the feature to the parent record is populated and a new primary key value is generated from the current date/time.

0 Kudos
by Anonymous User
Not applicable

Ok - so essentially, you're substituting the auto-generated globalID with a unique value you generate yourself, and populating fields you have defined in both tables with this value, correct?

That is something we might have to consider...but the app I'm working on is one component of a larger system working from the same data model, so it implies propagating changes to other applications that have never had a problem reading the GlobalID attribute of features.

I can, however, use the sqlite3 library in iOS to open the geodatabase and query the globalid field in the table for the feature with the matching object ID and most recent gdb_to_date.  Maybe that's bad practice, but it seems to work.

0 Kudos
MichaelDavis3
Occasional Contributor III

Pretty much.  We started using our own IDs before the offline geodatabase was a thing and we were having to use our own offline framework (and juggle JSON files).  Once the .geodatabase came into being we tried transitioning to use the built in relationship functions, but we were unable to successfully edit related records without getting weird errors. 

So we reverted to our old ID fields and haven't looked back.  All our db and web stuff use those ID fields rather than GlobalID.  Since our primary keys are built from device name and time stamp they have a nice side effect of giving us some additional information about the record that has come in handy once or twice.

DiveshGoyal
Esri Regular Contributor

Hi, Michael -

You're right, the SDK does not give you access to the GlobalID field. We originally made that field inaccessible because it is something that is managed by the underlying geodatabase model, and we didn't think it would be useful to application developers. But as you described, there valid cases where one needs it to manually establish relationships, or uniquely query features.

The GlobalID field will be accessible in the next release of the SDK.

_

Divesh

FaiyazKhan1
New Contributor

If you have the right SDK or latest, tried this in where clause:

"GlobalID = UPPER('{" + spatialGuid + "}')")

0 Kudos
ozcandurak
New Contributor III

Can you please Explain how can i get the GLOBALID from FeatureTableLayer in swift. Thank you Faiyaz Khan

0 Kudos