Survey123 Tell which repeat you are on

467
5
Jump to solution
08-06-2021 11:10 AM
ChrisSchreiber
New Contributor II

Hello all!

I am working on a survey that pulls in a JSON array and I want to make a repeat for each item in the array. I have found how to make the correct number of repeats, but I am unable to figure out how to tell which repeat I am on. I would like to know this so that I could put that number into the 'calculate' field to prepopulate fields within the repeats. 

ChrisSchreiber_0-1628273341389.png

If anyone knows if this is possible, please let me know! Thank you! 🙂 

 

Chris

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Notable Contributor

I do not know your function but my guess is you wrapped the whole thing in quotes so it is just a string.

"features[${rpos}].elt"  

You prob want something like "features[" + string(${rpos}) + "].elt"

Hard to tell.

View solution in original post

0 Kudos
5 Replies
DougBrowning
MVP Notable Contributor

position(..) is the way to do it now.  If you have nested repeats use position(${nameofrepeat})

0 Kudos
ChrisSchreiber
New Contributor II

Thanks Doug!

I can get the current repeat number using the 'position(..)' method. But, unfortunately, it does not seem to translate to the 'pulldata' function that I am using to get the JSON. 

ChrisSchreiber_0-1628277355930.png

ChrisSchreiber_1-1628277378272.png

The Pole Number field is dynamically trying to pull from the JSON by what repeat it is on. The Pole Description is just static at the 1st element in the JSON array. I would like both to be dynamic.

Thanks!

 

  

 

 

0 Kudos
DougBrowning
MVP Notable Contributor

I do not know your function but my guess is you wrapped the whole thing in quotes so it is just a string.

"features[${rpos}].elt"  

You prob want something like "features[" + string(${rpos}) + "].elt"

Hard to tell.

0 Kudos
ChrisSchreiber
New Contributor II

Thanks! That did the trick!

 

Much Appreciated!

 

Chris

DougBrowning
MVP Notable Contributor

Just in case:  Old habit to use + I should have mentioned that if you are going to use the web form at all + will not work and you must use concat() instead.  I only use the apps so I forget. Sorry.

0 Kudos