Select to view content in your preferred language

Auto-populated GUIDs via NEWID() function — In web map, display a more intuitive value in the Edit tool

208
0
3 weeks ago
Status: Open
Bud
by
Legendary Contributor

As @MobiusSnake pointed out in https://community.esri.com/t5/arcgis-online-questions/add-guid-field-to-existing-agol-survey123-feat...

Using a custom GUID field, it’s possible to automatically populate the field with GUIDs (at the hosted feature layer level) using the NEWID() function/default value via the Admin REST API.

{
  "fields":
  [
    {
      "name" : "MyID", 
      "type" : "esriFieldTypeGUID", 
      "alias" : "My ID", 
      "sqlType" : "sqlTypeOther", 
      "length" : 38, 
      "nullable" : false, 
      "editable" : false, 
      "domain" : null, 
      "defaultValue" : "NEWID() WITH VALUES"
    }
  ]
}


@Katie_Clark mentioned:

After creating the feature layer, I opened it in a web map and created a feature. At first I was worried because the interface looked like this:

Bud_0-1777491283920.jpeg


But after submitting the form and checking the attribute table, the value was populated!

Bud_1-1777491455311.png

I was also confused when the new feature Edit window showed NEWID() as the field value, prior to saving the feature. I thought it was going to insert the literal text “NEWID()” instead of a GUID value, which isn't what I want.

This idea is to display something more intuitive in the Edit tool’s field value text box, such as the GUID value, instead of “NEWID()”.