I'm testing the change log option for hosted feature layers but I don't think i'm using it properly so after some advice
Change tracking in a database should tell me 5 things
what was changed
who changed it
when they changed it
how it was changed (before/after)
but i'm not able to get all this info out of arc online - it just gives me the changed/current version without specifying which field was changed or what it was originally
How do i use the extractChanges api call so I can answer "what changes did this person make?"
I've done some other testing like trying to use the fieldsToCompare (didn't work - returned data even when comparing on fields i didn't change)
and changing the same field back and forth between 2 different values - it didn't capture any of the intermediate changes either.. just returns the current value.. what's the point of that?
My process:
I've uploaded/published a test fgdb to a hosted feature layer. I've turned on editing and change tracking
I modify one of the fields in an attribute table
followed this guide - How To: Extract Changes from the Change Tracking Table (esri.com) & api reference - Extract Changes (Feature Service)—ArcGIS REST APIs | ArcGIS Developers
(i just put in the layerIDs i was interested in and the minServerGen and serverGen I pulled out from the metadata call - left everything else default)
I'm able to make the rest call and get a json output and yes, it has the 'row' i modified, but it only shows the current/changed version. There's no corresponding record of the original
I also tried by running the call using a minServerGen of 0 and serverGen 999999 to make sure it would grab any/all versions
Surely agol keeps the original version, otherwise how would it know what's changed
I also tried using the fieldsToCompare option but the api returned the row even when i set it to compare a field i didn't change
Were you able to get anywhere with this? I am running into the same issue.
No, gave up.
After a lot of digging, trials and errors I believe I found out that the point of the extractChanges endpoint is to be used with webhooks.
I'm gonna play around with it a bit and report back if successful (in finally being able to track changes).
All right so you can create a webhook for your service and set it up so send info somewhere based on a couple of triggers, like when a feature is edited, created and deleted. It sends the extractChanges url with the serverGens and you can then query to get all the differences.
Example:
[
{
"name": "wh-agol",
"layerId": 0,
"orgId": "org_id",
"serviceName": "service_name",
"lastUpdatedTime": 1736978167698,
"changesUrl": "https://services1.arcgis.com/org_id/ArcGIS/rest/services/service_name/FeatureServer/extractChanges?serverGens=[2379724,2379725]&async=true&returnInserts=false&returnDeletes=false&returnAttachments=false",
"events": [
"FeaturesUpdated"
]
}
]
Here is the tutorial I did: Use webhooks to automate workflows in ArcGIS Field Maps
With make.com, you can connect your scenario to some instance of MSSQL or PostgreSQL or Google Sheets or soemthing else to store the serverGens and then use your prefered language to access it go through all the flow to get who and what changed. That's my next problem!
Quite complicated I think.
Hope it helps!