Hi,
I'm working on a workflow where a webhook fires when an attachment is added to a layer. This triggers a notebook on the notebook server to run which is code that will move this attachment to other tables based on ID. What I hoped to do in the notebook is use the extract_changes function because my layer has archiving enabled and in turn Change Tracking which I confirmed under capabilities on the REST services page. Using extract_changes, I would fetch exactly the attachments that have been added and then I could move them accordingly. That was at least my understanding of what I could do with this but I might've misunderstood the documentation.
The issue is I need the serverGens parameter and to do that I need to pull it from changeTrackingInfo. I was trying a line like this .
sg = flc.properties.changeTrackingInfo.layerServerGens[0].serverGenBut this doesn't work and it doesn't seem like i can access chnageTrackingInfo from properties at all.
I think there are other ways of going about this so if this doesn't work or I'm completely misunderstanding the functionally that that's alright but I was curious why this might be.
A few things:
Change Tracking must actually be enabled on the service, not just Extract. Check with "ChangeTracking" in flc.properties.capabilities. Archiving + a GlobalID column should auto-enable it on an enterprise geodatabase feature service, but verify rather than assume.
Build the FeatureLayerCollection from the service, not the layer. Your webhook gives you a single layer's URL. changeTrackingInfo only exists on the parent service object, so go up a level:
python flc = FeatureLayer(layer_url, gis).container
Match layerServerGens entries by id, not by position. Don't assume [0] — find the entry whose id equals your layer's own id.
Skip the manual serverGen lookup for the first run. Call extract_changes() with no layer_servergen to get a full extract. The response hands back the current layerServerGens itself.
Persist that returned serverGen somewhere durable (a small state file or table) so each subsequent webhook-triggered run can pass it back in as layer_servergen=[{"id": layer_id, "serverGen": last_gen}] for an incremental extract instead of a full one.
Confirm your installed arcgis package version's exact extract_changes signature (layer_servergen vs older servergen, and whether return_inserts_updates_deletes or the three separate return_inserts/updates/deletes flags apply), run help(flc.extract_changes) on the Notebook Server once to be sure, since this has changed across API versions.
Ok thank you I'll give that a try!