I'm build a survey in Survey123 Connect and it contains a number of repeats. I'm using the repeat_count parameter and count() to get how many repeats have been created in Repeat A and using that to generate prefilled repeats in Repeat B, but keep running into an issue. It seems that when adding counts together, instead of adding 1 + 1 to get 2, its returning 10. If I add a 3rd count on, instead of 1+1+1=3, it returns 100. What am I doing wrong?
In the screenshot below, I have 1 repeat each in 2 of the 3 repeat tables to be counted (Part_B_Part_C_Prevention_Risk_Controls_PRCs_System_Procedural_Controls and Part_B_Part_C_Prevention_Risk_Controls_PRCs_Plant_Equipment_Infrastructure_Controls) which is reflected correctly in label1 and label2 with "1" returned in each. But in label4, instead of showing "2", it shows "11". This is compounded in label5 with "110" being returned. It's like it's concatenating the values instead of adding them together.
This then results in 110 repeats being created in the destination table (instead of 2). I also don't seem to be getting the value passed across correctly (PRC to action) but thats a different issue and haven't dug into it yet.
Note - in the sample xls attached, I've set the fields to text to show in the form, but the intention is for them to be calculate fields and hidden.
Solved! Go to Solution.
Just the act of writing this up has helped me figure out whats happeneing. It's treating it as text isntead of a number and concatenating the values. I updated my formula to use the int() function around each field and it worked.
Before: ${nPRC_sys} + ${nPRC_plnt}
After: int(${nPRC_sys}) + int(${nPRC_plnt})
Now, jsut to figure out why it isn't passing the indexed values across properly (it's probably related to the returning of the value as text instead of an integer as well).
For calculate fields, text is the default return type. You can override this by setting the bind::esri:fieldType column to integer, or whatever other data type you feel appropriate. This should also allow you to get rid of the int() functions.
Just the act of writing this up has helped me figure out whats happeneing. It's treating it as text isntead of a number and concatenating the values. I updated my formula to use the int() function around each field and it worked.
Before: ${nPRC_sys} + ${nPRC_plnt}
After: int(${nPRC_sys}) + int(${nPRC_plnt})
Now, jsut to figure out why it isn't passing the indexed values across properly (it's probably related to the returning of the value as text instead of an integer as well).
For calculate fields, text is the default return type. You can override this by setting the bind::esri:fieldType column to integer, or whatever other data type you feel appropriate. This should also allow you to get rid of the int() functions.
Wouldn't the calculate field normally be created anyway? It's a hidden field on the form. You can set bind::esri:fieldType to null to prevent it from being added to the table.
I marked 2 solutions as both are valid - 1 where the field is retained and the other where the field is used to calculate temp values but isn't saved to the feature service.