Select to view content in your preferred language

Auto-populate unique ID field in hosted feature layer (common ID between copy/pasted features in ExB)

337
5
a week ago
Bud
by
Legendary Contributor

In Experience Builder > editor widget, I am manually copying features from layer1 into layer2. Layer1 is a Survey123 hosted feature layer.

I want there to be a common ID between the two features so I can know what the layer1 source feature was for the layer2 destination feature.

Is there a way to auto-populate a unique ID field in layer1 in AGOL?
For example, is there a way to automatically populate a custom ID field in layer1 with the OBJECTIDs? My assumption is that OBJECTIDs can't be copy/pasted into new features, but values from a custom ID field can.


Related Experience Builder Idea: Field mapping for copying/pasting features using Editor widget

0 Kudos
5 Replies
Katie_Clark
MVP Regular Contributor

Right now I have a similar use-case and I am using a scheduled Notebook to assign UUID's after a feature is created.

If there's a way to get this to automatically populate on creation I'd love to know!! But I wasn't able to find it in my initial research when I set this up a while back....fingers crossed maybe I just missed something and it's actually possible? 

Best,
Katie

If this post helped you, please consider giving a kudos and/or marking as the accepted solution. Thanks!
Bud
by
Legendary Contributor
0 Kudos
Neal_t_k
MVP Regular Contributor

@Bud Since you mentioned Survey123 if you are using Connect, there is uuid() function you can use to populate a unique id

Also, there should be GlobalID in your Survey123 layer (layer1) already that you could copy to layer 2

https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformformulas.htm

Bud
by
Legendary Contributor

@Neal_t_k  Thanks for the info about Connect! I don't have experience with it. I will look into it.


Also, there should be GlobalID in your Survey123 layer (layer1) already that you could copy to layer 2

I've wondered about this too. The ExB copy/paste functionality seems to copy/paste into fields that have exactly the same field name.
However, as far as I can tell, the destination feature gets a different/new GlobalID, not the GlobalID from the source feature. So I think I'm out of luck here.

I'm not aware of a way to "field map" the source GlobalID to a custom destination field like ORIGINAL_GLOBALID.  Experience Builder Idea: Field mapping for copying/pasting features using Editor widget

0 Kudos
Bud
by
Legendary Contributor

From a 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"
    }
  ]
}

 

0 Kudos