Populate repeat fields by index from a multiple choice question

1547
3
12-29-2020 12:41 PM
KimberlyMcCallum
New Contributor III

I am trying to use the results of a multiple choice question to automatically generate and populate repeat records. I decided this was possible after reading this post and response by @JamesTedrick but I'm struggling to implement the suggested solution. I used the count-selected(${question}) in the repeat_count field to set up the number of repeats. I am trying to figure out how to populate the treatmentName field based on the selected values by their index. As suggested, I am using the once() and count() functions but I don't really understand how these should work in this context and am even more confused by the fact that I have something that appears to work when previewed locally in Survey123 Connect but doesn't work when I publish the survey... 

In the attached survey I have an outer repeat with a multiple choice question for treatments. The number of selected treatments is used to generate the number of treatment repeats (this works) and I'd like the treatment value to be populated in the treatmentName field (this doesn't work). Can anyone help me troubleshoot how to pull the treatment names into the repeats? 

Also, this is a simple test example to learn how to do this. Eventually, I will be trying to edit an existing feature service with related records. I read that Survey123 webforms do not support nested repeats and I'm confused as this approach seems to be working (with the exception of automatically populating the fields). I would would be grateful for any clarification here! 

Thanks in advance!

3 Replies
DougBrowning
MVP Esteemed Contributor

Not sure about the webform part but I do a lookup based on repeat number so that I can have 1=A, 2=B, 3=C, etc.

I do the once(count) then a pulldata to a csv to translate.

Type   Name    Calculation

calculate RepeatCount   1
calculate TransectNum  once(count(${RepeatCount}))
calculate Transect   pulldata('TransectCodesMid', 'TransectLetter', 'TransectNum', ${TransectNum})

CSV is attached inline images seem broke.

 

Hope that helps.

KimberlyMcCallum
New Contributor III

Hi @DougBrowning! Thank you for heeding my call for help! It looks like your application is/was somewhat different than mine; however, based on your example, I was able to fix my XLS form syntax and make it work reliably in Survey123 Connect locally. Thanks! Unfortunately, when I publish the survey, the automatic population of the repeat fields based on the select_multiple question does not work and I fear that this is simply due to nested repeats not being supported in the Survey123 web form? My next move will be to find and add to the feature request list and then find a clever workaround where I don't need to have nested repeats! 

For my workflow, I have multiple surveys that target a somewhat complex existing feature layer with related tables. The parent feature layer contains fire incident point locations with related tables containing 1. threatened resources and 2. mitigation treatments. In my schema currently, these two related tables are modeled as siblings (related via the fire point parent) but in my survey, I want a user to be able to select multiple treatments within the threatened resources repeat and have these values automatically populated in the mitigation treatment repeats... I know it's a bit complicated to explain but if you or anyone has a clever idea for how to approach this, I'd be very grateful! 

Best, 

0 Kudos
DougBrowning
MVP Esteemed Contributor

I am not sure on the webform and repeats.  But I would try the app and see.  If that works use the app.  For fires you will prob be offline and need a app anyway.

But it sounds more like you want 2 diff repeats in the same form instead of a nested?  I would need to see more of your form.  Post or you can DM me.

0 Kudos