Select to view content in your preferred language

Auto Increment ID attribute rule

191
4
a month ago
Labels (1)
SanchezNuñez
Frequent Contributor

Good morning,

 

Can we add an attribute rule to a hosted feature class to calculate the next value for an ID?


I created a feature class in ArcGIS Pro with an attribute rule to Auto Increment the ID, and published the feature class as a hosted feature in AGOL, but the rule is missing.

Thanks

 

0 Kudos
4 Replies
MErikReedAugusta
MVP Regular Contributor

My information might be out of date, since I haven't followed the most recent changes to AGOL, but I don't think Attribute Rules and NextDatabaseSequence are currently supported in AGOL.

You could maybe create a workaround by embedding an auto-calculated script that reads all existing records and returns the next ID, but then I think the Attribute Rule in Pro might start returning duplicates, since it doesn't check existing records to make sure the value is unused.

You might want to check out these two submissions to the AGOL Ideas board:

https://community.esri.com/t5/arcgis-online-ideas/support-for-attribute-rules-in-arcgis-online/idi-p...

https://community.esri.com/t5/arcgis-online-ideas/allow-feature-services-to-maintain-attribute-rules...

I think the other official suggestion right now is to host in Enterprise and REST out to AGOL, if memory serves.

------------------------------
M Reed
"The pessimist may be right oftener than the optimist, but the optimist has more fun, and neither can stop the march of events anyhow." — Robert A. Heinlein, in Time Enough for Love
0 Kudos
SanchezNuñez
Frequent Contributor

Thanks @MErikReedAugusta 

How do you create an auto-calculated script   in AGOL?

0 Kudos
MobiusSnake
MVP Regular Contributor

Although I haven't done this myself, I think you could do it with a webhook.  Write the webhook to capture the feature's details, perform the calculation, then write back to it.  There's going to be a brief delay and I'm not sure you'd see the calculation reflected immediately.

Here's a blog post on setting up webhooks in AGOL:

https://www.esri.com/arcgis-blog/products/arcgis-online/sharing-collaboration/how-to-create-a-hosted...

If editing is primarily taking place through web map forms, you can do calculations in those as well, although they won't be applied if editing occurs in other contexts (like REST API calls).

0 Kudos
MobiusSnake
MVP Regular Contributor

Quick addendum, another option is to used a scheduled notebook to set IDs on all features that currently have null values, however this involves a significant delay and wouldn't be appropriate for time-sensitive workflows.

0 Kudos