Any thoughts as to the Python-based approach?
If your service has editor tracking enabled, and thus a last_edited_date field, this kind of thing would be incredibly simple. You'd need to keep track of when the script was last successfully run, perhaps with a config file. I have a script that does this sort of thing, though it only runs daily. Still, the whole thing only takes a couple seconds to run, so this could be firing many times a minute with room to spare.
from arcgis import GIS
from configparser import ConfigParser
from datetime import datetime
# portal connection
gis = GIS('your portal url', 'user', 'pass')
# get layer
fl = gis.content.get('itemid of service').layers[0] # or whatever layer index applies
# read config file
config = ConfigParser()
config.read('config.ini')
# get last run timestamp from config
last_run = config.get('last_run', 'time')
# calculate field, using timestamp to selectively identify new adds/edits
fl.calculate(
where = f"last_edited_date >= timestamp '{last_run}'",
calc_expression = {'field': 'MXCREATIONSTATE', 'value': 1}
)
# set last run timestamp to current date
config.set('last_run', 'time', datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
with open('config.ini', 'w') as c:
config.write(c)
Note that the method you use to query a layer based on a timestamp may differ depending on your DB. We're on postgreSQL, so timestamp 'YYYY-MM-DD HH:MM:SS' is what we use.
- Josh Carlson
Kendall County GIS