This idea is to create an auto-incrementing integer field using the AGOL UI. The mechanism would be at the AGOL feature layer level, not at the app level, so it can be used globally.
The OBJECTID field isn't suitable because it can't be used everywhere, such as for copy/pasting features in the Experience Builder editor widget. Further, it's generally considered unwise to rely on OBJECTIDs.
Related AGOL Question: Auto-populate unique ID field in hosted feature layer (common ID between copy/pasted features in ExB...
I'll add to this and describe my use-case for a similar functionality, whether it's an integer specifically or a UUID field (which is what I'm using).
In my case, we're working with datasets that depend on unique ID's, and we need these maintained for data integrity regarding relationships in external postgres databases. We can't rely on the auto-generated ObjectID's or GlobalID's since those would not be preserved if the layer ever had to be overwritten. Right now, the solution I have is to use a scheduled ArcGIS Online Notebook that scans the dataset every 15 minutes for features that don't have a UUID assigned in our "uniqueID" field and populates it. The downside to this (besides credit usage) is that there is a potential for up to a 15 minute delay of when a user creates a feature in an AGOL app and when it actually displays in the external app I'm building which integrates with the feature layer, since we require that unique ID and don't display features that don't have it assigned yet.
It's really a suboptimal solution and would be solved if something like attribute rules or other auto-calculation functionalities were allowed in AGOL feature layers.
@Katie_Clark It's kind of a headscratcher why this functionality doesn't already exist. Stable unique IDs are data management 101. A must-have.
Yup, this has been a bit of a headache for a number of years and it's not great to try and rely on another process to run. Would solve a lot of inspection and data collection issues if we could apply a simple rule or arcade element.
@JonathanMcD, you might like @MobiusSnake’s comment in Add GUID field to existing AGOL Survey123 feature layer — Field not auto-populating?
GUID fields don't autopopulate, they default to null. They're typically up to the application or an editor to set.
You could make a hidden field in your S123 form for the question and use the uuid() function to populate it.
Alternatively, you can use the Admin REST API to create the field with a NEWID() default value, with the Add to Definition endpoint of the layer. It may be possible to update an existing field's default value with this as well, but I haven't tried it. This will make the field autopopulate with a new value in the same way that Global IDs are autopopulated:
{
"fields":
[
{
"name" : "MyID",
"type" : "esriFieldTypeGUID",
"alias" : "My ID",
"sqlType" : "sqlTypeOther",
"length" : 38,
"nullable" : false,
"editable" : false,
"domain" : null,
"defaultValue" : "NEWID() WITH VALUES"
}
]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.