creating a unique GUID on a mobile device

1750
2
Jump to solution
02-13-2017 12:39 PM
by Anonymous User
Not applicable

Let's say a feature class had a user created GUID field that was used as the foreign key in a related table.

If a new feature was created on a mobile device, is there any method in App Studio or the ESRI Qt runtime that would create a new unique GUID?

Or, alternatively, would there be any downside to seeding this custom field with the system generated GlobalId? I assume not, given that, even if the GlobalId changed later on (perhaps as this record might get extracted and reappended, etc), the chances (??) of another feature ever getting the same GlobalId as a previous feature should be minimal to non-existent??

I realise that the second part of question is not expressly an App Studio question! But interested in anyone's comments.

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi Paul,

For the first part of your question, there is a method in the AppFramework QML type called createUuidString() which you can use to generate UUID/GUID strings.

string createUuidString()

Creates a universally unique identifier (UUID) string; a 128-bit number to use as a way to identify a particular object or component. Without a defined format, defaults to using curly brackets and hyphens.

string createUuidString(int format)

Creates a universally unique identifier (UUID) string; a 128-bit number to use as a way to identify a particular object or component.

For example,

var currentItemUuid = AppFramework.createUuidString(1);
var thisFilename = (currentItemFilename !== "") ? currentItemFilename + "_" + currentItemUuid : "export" + currentItemUuid;

The format parameter.

0 to include curly brackets and hyphens, e.g. {3F2504E0-4F89-41D3-9A0C-0305E82C3301}. 1 to include hyphens but not curly brackets, e.g. 3F2504E0-4F89-41D3-9A0C-0305E82C3301. 2 to not include hyphens or curly brackets, e.g. 3F2504E04F8941D39A0C0305E82C3301.

For the second part, what I understand is that you want to know if there are any downsides of using the system generated GlobalID itself and copying it to the custom GUID field. It doesn't seem to have any major downside, apart from the possibility that the same number in multiple columns might be confusing. The GlobadID surely is unique and the chances of any previous feature having the same Global ID are nearly non-existent.

Hope this helps.

Thanks,

Anshuman

View solution in original post

0 Kudos
2 Replies
by Anonymous User
Not applicable

Hi Paul,

For the first part of your question, there is a method in the AppFramework QML type called createUuidString() which you can use to generate UUID/GUID strings.

string createUuidString()

Creates a universally unique identifier (UUID) string; a 128-bit number to use as a way to identify a particular object or component. Without a defined format, defaults to using curly brackets and hyphens.

string createUuidString(int format)

Creates a universally unique identifier (UUID) string; a 128-bit number to use as a way to identify a particular object or component.

For example,

var currentItemUuid = AppFramework.createUuidString(1);
var thisFilename = (currentItemFilename !== "") ? currentItemFilename + "_" + currentItemUuid : "export" + currentItemUuid;

The format parameter.

0 to include curly brackets and hyphens, e.g. {3F2504E0-4F89-41D3-9A0C-0305E82C3301}. 1 to include hyphens but not curly brackets, e.g. 3F2504E0-4F89-41D3-9A0C-0305E82C3301. 2 to not include hyphens or curly brackets, e.g. 3F2504E04F8941D39A0C0305E82C3301.

For the second part, what I understand is that you want to know if there are any downsides of using the system generated GlobalID itself and copying it to the custom GUID field. It doesn't seem to have any major downside, apart from the possibility that the same number in multiple columns might be confusing. The GlobadID surely is unique and the chances of any previous feature having the same Global ID are nearly non-existent.

Hope this helps.

Thanks,

Anshuman

0 Kudos
by Anonymous User
Not applicable

Thanks Anshuman, that createUuidString method is exactly what I was after.

Cheers,

-Paul

0 Kudos