Select to view content in your preferred language

Survey123 if statement and indexed repeat TypeError

264
5
Jump to solution
07-28-2025 10:20 PM
JeetzPatel
Occasional Contributor

Hello all, I hopefully have a simple one. My S123 form aims to help users populate information for asset inspections. For some assets, they may have repeatable sections that have the same information between sections, hence I'd like to minimise how much data entry occurs on site.

In my S123 xlsx, I am attempting to populate a second repeat based on the answers of a previous repeat. My logic in the calculation field for the second repeat (for Q6) is:

if(${Q5}=1, indexed-repeat(${Q3}, ${RepeatA1A}, position(..)), '')

The aim here is to populate Q5 with 1 or 0 (Yes/No) based on if this asset's particular section has the same information as the other section. However, this calculation throws a "TypeError" in Q6:

JeetzPatel_0-1753765862814.png

I have looked at other help questions with similar issues and have changed the esriFieldType but can't pinpoint the esriFieldType I need. I have also changed Q6 to "calculate" instead of "select_one material" but this just makes Q6 not appear correctly:

JeetzPatel_1-1753766059965.png

JeetzPatel_2-1753766069359.png

Additionally, when I change the calculation to:

indexed-repeat(${Q3}, ${RepeatA1A}, position(..))

There are no issues with Q6, however I'd like users to have to option to decide whether or not the autopopulation of the repeat needs to occur or not.

I have attached my xlsx for context. Has anyone got some ideas? Any feedback is greatly appreciated. Thank you 🙂

 



Tags (1)
0 Kudos
1 Solution

Accepted Solutions
DeonLengton
Esri Regular Contributor

split your calc in two for the retrieval of the selected material in the first repeat

see attached Excel file... hope it helps

View solution in original post

5 Replies
DougBrowning
MVP Esteemed Contributor

Q5 is a string have you tried quotes on the 1?   

if(${Q5}= "1", indexed-repeat(${Q3}, ${RepeatA1A}, position(..)), '')

Also it looks like you want to check in the same repeat number?  If so no need to index it at all.

Just  if(${Q5}= "1", ${Q3}, '')  would work.

Try that.

0 Kudos
JeetzPatel
Occasional Contributor

Thanks Doug. The quotes didn't work unfortunately. I checked not using indexed-repeat and found that if I create say 1 repeat record in the first repeat, then copy it using this method in the second repeat, if I then create another record in the first repeat, the value of the first record in the second repeat get overwritten with the values of the second record in the first repeat, which is not ideal in my case 😞

0 Kudos
DougBrowning
MVP Esteemed Contributor

Sorry I missed that these are two different repeats.  I think Deon answer may help as some functions do not fire correctly inside an if.  You still probably need "1" as these are lists so it will be a string.

Try that.

DeonLengton
Esri Regular Contributor

split your calc in two for the retrieval of the selected material in the first repeat

see attached Excel file... hope it helps

JeetzPatel
Occasional Contributor

Thanks Deon, this worked pretty well. The need for another field is tough but I can work with that.

0 Kudos