Select to view content in your preferred language

Trigger updates to features' EditDate field when users modify Attachments on hosted Feature Layer

214
1
2 weeks ago
Labels (2)
EmThompson_metra
New Contributor

In my organization's ArcGIS Online content, I have a Feature Layer (hosted) with 1 Point layer that is edited by users in the field via Web map. The layer has fields like Name, Category, Description, Comment, but it also has Attachments (field users attach images of the real world at the point location). When an editor in the field updates those other fields - such as they add a Comment - this action results in the EditDate field automatically getting updated to reflect that change was made at that time; however, when the only edit or change the field user makes is a modification to the Attachments (to add, update, or delete an attachment or attached image), the EditDate field does not get updated. I have a downstream workflow that scans the feature layer for updates and consequentially creates or updates records in another software when there are changes detected; however, changes to Attachments are not being detected, because they don't affect the EditDate field, or any other temporal attribute in the main table. 

Is there a way for the feature's main attribute table to get updated / to trigger an update to the EditDate field on the feature level when Attachments is modified? Or, how can changes to attachments be detected? 

(I thought maybe I could do this with Webhooks, but it looks like a webhook receiver needs to be configured outside of ArcGIS Oline, and I want to be able to have Attachment changes detected within AGOL). 

0 Kudos
1 Reply
MobiusSnake
MVP Regular Contributor

I can't think of an easy way to do this, but there may be a convoluted way using a Notebook.

  • Add a new field to your feature layer and call it "attachments_hash" or something like that.
  • In your notebook, query the attachment details for each feature, this will return a JSON list of metadata for the attachment (name, size, etc. - no date/time unfortunately).  Convert each set of  these "attachmentInfos" to a hash value, compare it with the attachments_hash value in your main layer, and if it's changed, update it.
  • This change will get picked up downstream.
  • Schedule your notebook to run every 15 minutes or so.  (You can't schedule it any more frequently than 15 minutes, I think.)

Definitely some limitations to this, too.

  • There's a possibility the sequence causes you to briefly miss some changes - imagine an edit occurs, your downstream process runs, then the notebook scheduling kicks in.  Your update won't get picked up until the next run.
  • If someone adds an attachment then immediately deletes it, it might not get picked up at all.
  • If you're dealing with a large amount of data the process might not be very quick and it could chew up credits.