Is there a way to retrieve date that media file was last updated and capture it in Survey123 field?

427
3
08-17-2020 12:58 PM
JamesKelly4
Occasional Contributor

Can this be done via pulldata or perhaps through a java function? I have never done a javascript function before, but I did just read this article. I would like to add this date as a calculated field in my chronic wasting disease (CWD) surveillance app. I have a series of scheduled R scripts update several .csv files in my media folder on my PC, and I have several updateMediaFolder.py scripts that run a lagged schedule that then update those files in the cloud. This works great for QA/QC on several fields that we track in our database. However, when the user forgets to redownload the survey or one (or more) of my scripts isn't working, the user enters the data manually which inevitably leads to a lot more errors. Therefore, I would like to have a field that shows when those media file folders were last updated. Any help is greatly appreciated! James Tedrick Ismael Chivite survey123 calculations 

Tags (1)
0 Kudos
3 Replies
JamesKelly4
Occasional Contributor

James Tedrick‌ sorry to bug you man, but might you be able to help me on this one? Thanks!

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hello James Kelly‌, 

Depending on your WebGIS infrastructure (ArcGIS Online, ArcGIS Enterprise (hosted or registered)) one option, would be to add a field to your feature service (text or date). At the end of the updateMediaFolder script after the updated zip file is uploaded you can use the ArcGIS API for Python to calculate the field using the current time the script was run. 

If you don't need the time in your survey you wont need to update the survey. If you need need the time in the survey you can add the field in Connect and republish it. If your colleagues are using the inbox to edit existing records they will see the last sync time (assuming it is not a new record that was submitted since the last run of the script) 

Please use these links for resources to calculate the field using the ArcGIS API for Python: 

Calculate Field—Portal for ArcGIS | Documentation for ArcGIS Enterprise 

arcgis.features module — arcgis 1.8.2 documentation 

With the 3.10 release of ArcGIS Survey123 you can also require users to update to the latest version of the survey before submitting responses. Please use this link for reference: Publish a survey—ArcGIS Survey123 | Documentation 

Thank you, 

Zach

Thank you,
Zach
JamesKelly4
Occasional Contributor

Thanks Zachary Sutherby‌. I will have to dig into this a little more. Regarding your last point about requiring users to update to the latest version, what constitutents a new version of the survey? When I republish it via Connect? Or would a scheduled run of updateMediaFolder.py trigger the user to update the survey? If the latter is true, then I think that would negate the need for me to have a note in the survey showing how old the files in the media folder are. Thanks again!

0 Kudos