Implement auto export of data triggered by submission, that is uploaded/linked to media folder of another survey

1127
5
02-01-2022 06:04 PM
LMedeirosUI
Occasional Contributor

I am VERY new to Survey123, and am having to learn a lot to get two surveys working in way less time than it should be given. Just a disclaimer.

I have two surveys - one for collection of data/fish and one for subsequent sampling of the collected fish. I need the sampling form to link to the collection form so that some information is auto populated and readily available. We use PIT tags as the unique ID in both forms, so this works fairly well using a custom javascript query function within the pulldata() calculation. It actually works perfectly fine except for the fact that it (1) requires an active internet connection and (2) seems to bog down the form. The pro of using this is that collection and sampling can be nearly simultaneous and does not require a manual download of the collection data into a CSV file. As the collection form is normally uploaded just prior to the sampling form being used at the holding facilities, this is an important point.

So I was wondering if there was a way to have an auto export of the data (as a CSV file) that is "triggered" by submission of the collection form. This file would then be stored/linked to the media folder of the sampling form, overwriting the previous version (or maybe just adding records to it? that seems more complicated). After this was done, all the user would need to do is update the survey (I think of this more as "syncing" the data in this case) and their machine wouldn't need a constant internet connection and the form should run faster without the javascript query.

Have I missed something obvious? Am I trying to do too much? Any help or suggestions would be appreciated.

Thank you!

0 Kudos
5 Replies
LMedeirosUI
Occasional Contributor

While looking up information about triggers, I found mention of Survey123 Microsoft Flow connector. Sounds like that might work. Anyone have any experience with it when using it to enter rows into a spreadsheet?

0 Kudos
DerrickWestoby
Occasional Contributor III

I use Integromat instead of Microsoft Flow, but very similar.  In a few of my scenarios, I'm adding all of the repeat records for that specific submission to a Google Sheets file and then exporting to a CSV.  It should be possible to accomplish what you're after by doing something similar and then using the ArcGIS REST API to overwrite your "linked content" CSV in your AGOL account with your updated CSV. I have updated feature attributes via Integromat  in one of my scenarios, but not a linked CSV...fyi.  Also, I believe that updating the linked CSV will only automatically trigger an update that iOS field app users will see. In my experience, I need to download the linked CSV in S123 Connect and then re-publish for Android users to see the updates). 

Integromat scenario for hazmat sampling:

DerrickWestoby_0-1643912298931.png

 

Branch that creates Asbestos samples CSV (In this case, from a repeat layer in the survey):

DerrickWestoby_1-1643912339265.png

Create new google sheet -> Define the headers -> Move CSV (because I can't define the folder location when creating the CSV) -> Iterate through each record ->  add record as a row

DerrickWestoby_2-1643912488336.png

 

DerrickWestoby_3-1643912515129.png

 

In your case, I imagine that you'd want to do something like:

JSON Query Collection Layer & Parse response -> Create a new CSV and populate the headers from your parsed query -> add a row for each record -> Export as CSV (With same name as your current linked CSV)-> Overwrite AGOL-Hosted CSV file. 

You could probably skip the whole query & CSV setup if you just use the REST API to export the layer as a CSV file directly. 

 

edit: This was the first time I set up a scenario to update existing features so it's a little wonky, but it works (and I couldn't get it to work via the query string options previously)

DerrickWestoby_4-1643912821547.png

 

LMedeirosUI
Occasional Contributor

Thank you! I will look into this and see if it would be an option! 

0 Kudos
RobynSnookCCB
New Contributor III

Hi! Did you ever get this to work? I'm trying to do something similar. Thanks

0 Kudos
LMedeirosUI
Occasional Contributor

Hi @RobynSnookCCB - I gave up. I was (and still am) new to Survey123/ArcGIS and found this a bit too much. I'm looking into it again, though, so if you found something that worked I'd like to know.

Otherwise, what I did get to work was a java script that used JSON data and pulldata to query a layer of another (submitted) survey. Obviously this requires internet and is a pretty big drag on loading the form. If you'd like more information let me know.

0 Kudos