Actually, now that AGOL Notebooks have introduced notebook scheduling, a script that runs schedule is totally an option, even for AGOL-only users! And a simple field calculate would cost you next to nothing in terms of credits, even if the script ran fairly often.
But to your question, the simple answer is "you can't". I recall hearing at some point that Attribute Rules are part of AGOL's long term plan, but for the time being, you just can't have a field that updates itself. There needs to be some human (or scripted) interaction to update a field.
If you do decide to take the Python approach, we had a script running via an AGOL notebook that did just this sort of thing, making use of the calculate method. Here's a simplified version of it:
from arcgis import GIS
from arcgis.features import FeatureLayer
gis = GIS('https://arcgis.com', 'username', 'pw')
fl = FeatureLayer('url to your layer', gis=gis)
id_sql = "some SQL expression to derive your unique ID"
fl.calculate(
where = 'uniqueIDfield IS NULL',
calc_expression = {'field': 'uniqueIDfield', 'sqlExpression': id_sql}
)
And that's it! By specifically targeting rows that have no unique ID calculated yet, each run of the script only has to calculate values for a handful of rows, if any, and the entire process only takes a few seconds. At the current rate of 1.5 credits per hour, you're probably looking at a cost of 0.005 credits per execution.
- Josh Carlson
Kendall County GIS