Select to view content in your preferred language

Survey 123 template in App Studio - load multiple predetermined surveys

1127
6
Jump to solution
10-01-2019 11:25 AM
YuliaMamonova
Frequent Contributor

Hello guys,

I am trying to change the template in a way that it downloads all surveys available for a user when the user opens the app for the first time, and then updates all of them on opening the app.

I successfully got it work for another app, but only for 1 survey.

Is it possibly to do the same for multiple surveys?

Thank you!

Tags (2)
1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi Yulia,

I think that the downloading sequence is happening too fast - the second download is attempting to start before the downloaded() signal for the first form has been fired.  To accommodate this, I restructured the loop to be incremented by the onDownloaded function in the OpenParametersPanel. The specifics are (All on SurveysGalleryPage.qml😞

1. Create properties for SurveysGalleryPage that are the list of forms and the current position in the index:

2. Begin the download of the first item in Component.onCompleted and have a handler for dl_num to download the next survey when that variable is incremented (I placed this immediately below the property statements:

3. In the OpenParametersPanel, add the loop logic and incrementation to increase dl_num after a download has succeeded:

4. (Optional).  The OpenParameters were designed with the expectation that only 1 survey would be requested when the app is opened; part of the workflow of using OpenParameters is to open the form after download.  This is done through the selected() function in checkOpenParameters().  Since you are downloading multiple forms, it's not known which form should be immediately open after download; to prevent both forms from opening on the stack, I disabled the selected() function:

If you know which should be opened, you could instead check for it based on itemID.  The other forms would continue to download.

View solution in original post

6 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Yulia,

This might be better addressed in the AppStudio for ArcGIS‌ forum.  If you have the code working for one survey, you should be able to get it to work inside a for loop or similar to download multiple.

0 Kudos
YuliaMamonova
Frequent Contributor

Yes, thank you, that's what I thought. I just barely know JS, but I will try for loop.

Thank you,

Yulia

0 Kudos
YuliaMamonova
Frequent Contributor

Hi James,

I tried for loop to iterate through an array with item ids that I want to download, but it still only downloads the first one when I run. Please look at my code:

I run it in QT Creator, and this is what I see:

It checks the second form too, but it's not downloading it. Please suggest!

 

Thank you,

Yulia

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Yulia,

I think that the downloading sequence is happening too fast - the second download is attempting to start before the downloaded() signal for the first form has been fired.  To accommodate this, I restructured the loop to be incremented by the onDownloaded function in the OpenParametersPanel. The specifics are (All on SurveysGalleryPage.qml😞

1. Create properties for SurveysGalleryPage that are the list of forms and the current position in the index:

2. Begin the download of the first item in Component.onCompleted and have a handler for dl_num to download the next survey when that variable is incremented (I placed this immediately below the property statements:

3. In the OpenParametersPanel, add the loop logic and incrementation to increase dl_num after a download has succeeded:

4. (Optional).  The OpenParameters were designed with the expectation that only 1 survey would be requested when the app is opened; part of the workflow of using OpenParameters is to open the form after download.  This is done through the selected() function in checkOpenParameters().  Since you are downloading multiple forms, it's not known which form should be immediately open after download; to prevent both forms from opening on the stack, I disabled the selected() function:

If you know which should be opened, you could instead check for it based on itemID.  The other forms would continue to download.

YuliaMamonova
Frequent Contributor

James,

Thank you very much! Will try it right now!

0 Kudos
YuliaMamonova
Frequent Contributor

James,

Thank you SO MUCH, it works perfectly!!!

0 Kudos