Select to view content in your preferred language

Attempting to make the default value of a repeat question the value at previous index

667
5
Jump to solution
01-23-2025 09:57 AM
ClaireFSmith
Emerging Contributor

I've got a repeat that collects species information for veg monitoring. Often times, crews will need to add several repeats for the same species, so I'd like to make the default value for Species the value of the previous repeat to minimize the number of times the crew will need to fill that field. So, in Species if Achilliea millefolium is selected in repeat 1, I'd like for repeat 2 Species field to default Achilliea millefolium, same for repeat 3, 4, etc. then when they are done with that species and at repeat 7 they choose Ambrosia tomentosa, I want repeat 8, 9, etc. to default to this species. (This is just an example, it would not always happen at the 7th instance)

From what I've read it seems like indexed-repeat would not work since it can't be used in the repeat it is calling, so I'm not sure where to go from here. Thank you for any help, I am pretty new to Survey123!

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

Kinda sorta not really.  See my post here for all the details.  For sure my number 1 ask the last few years now.

https://community.esri.com/t5/arcgis-survey123-questions/prepopulate-answers-in-a-repeat-with-last-v...  

View solution in original post

0 Kudos
5 Replies
DougBrowning
MVP Esteemed Contributor

Kinda sorta not really.  See my post here for all the details.  For sure my number 1 ask the last few years now.

https://community.esri.com/t5/arcgis-survey123-questions/prepopulate-answers-in-a-repeat-with-last-v...  

0 Kudos
ClaireFSmith
Emerging Contributor

Thanks for your reply!! I added the function to scripts and pulldata to the calculation column for Species, but am getting this error 

Invalid calculate for the bind attached to "${Species}" : Couldn't understand the expression at this point: ...ion, position(\xcd\x8e\xe2\x80\xa6),"Species") in expression pulldata("@javascript","functions.js", "sameaslast",${VegetationComposition},position(\xe2\x80\xa6),"Species")\n\nResults: Invalid

 

This is the pulldata I used 

pulldata("@javascript", "functions.js", "sameaslast", ${VegetationComposition}, position(…), "Species")

 

I tried changing forcing the esribindtype to string and changing the question type to text and still got the same error. Would you happen to know what is breaking it? I read through the replies to the post you attached and did not see similar errors. Thanks!

0 Kudos
DougBrowning
MVP Esteemed Contributor

Looks like you have 3 periods when it should be 2 in position.  I would actually use ${NameofRepeat} instead as it is safer.

0 Kudos
ClaireFSmith
Emerging Contributor

Oh gosh thank you easy fix! This is so great. I saw that when you used this it crashed because of the size of the repeat. Do you mean the number of questions inside the repeat, or the number of records you were adding? Ours is pretty short with only the 4 questions, but will sometimes need upwards of a couple hundred records for sites. Thank you again for your help!

0 Kudos
DougBrowning
MVP Esteemed Contributor

I am not sure but I think it does send the entire repeat table.  That is why we could not use it.  So keep an eye on it for sure.  If it works mark as a solution please.

0 Kudos