Text field within repeat clearing when paging between repeats

459
8
Jump to solution
09-07-2022 09:29 PM
DustyJordan
New Contributor III

Hello,

I've just noticed an issue occurring within one of my Survey123 forms and I'm wondering if anyone knows how to resolve it. 

I have a conditional text field within my repeat that becomes relevant and required when "Other" is selected on another field. This essentially allows the user to input something that isn't present in the choice list. 

I noticed today that when I move on (forward or backward) to another repeat and then page back the relevant field text input is cleared from the field. I'm assuming this has something to do with the order in which the relevant expression is being triggered? 

Any insight or workaround would be appreciated.

Thank you!

-Dusty

0 Kudos
1 Solution

Accepted Solutions
LaurenceTait
Occasional Contributor II

Well, that is just bizarre. You've discovered a serious bug.

The problem is being caused because the same formula is in both the [required] and [relevant] fields.

You can obtain the result you want by using any of the three following formulas:

regex(${Species_Common}, 'Other')

${Species_Common} = 'Other'

selected(${Species_Common}, 'Other')

You can put any formula into the [relevant] or [required] fields, and it works perfectly. And you have to have a formula in both fields.

But of you put any formula into both fields the problem you saw manifests.

That's a pretty serious bug you've discovered, and probably should be reported.

Anyway, there's a simple workaround for your purposes. Select any two different formulas and put them into the [required] and [relevant] fields respectively. Alternatively use the same formula, but put it into the [body::esri:visible field] instead of the [relevant] field.

View solution in original post

8 Replies
LaurenceTait
Occasional Contributor II

You'll have to provide more information. Ideally upload the xlsx form. It's not clear from your description exactly what is happening.

When you say that it becomes triggered "when "Other" is selected on another field", do you mean another field within the repeat, or another field outside the repeat?

When you say that you "move on to another repeat and then page back the relevant field", do you mean that you literally move on to another repeat, or that you move onto another instance within the same repeat, or do you mean that you have nested repeats?

And when you say that you "page back the relevant field", do you mean that you are altering the value of the field that determines the relevance of the text field?  Or that you are returning to a previous instance within the same repeat or that you are returning to a previous page within the same survey that also contains a repeat? 

DustyJordan
New Contributor III

Hi Laurence, 

Thanks for the response. I'll attach the xlsx form, but let me break it down a little better so it is clearer for you. 


When you say that it becomes triggered "when "Other" is selected on another field", do you mean another field within the repeat, or another field outside the repeat?




There is a field within the repeat named ${Species_Common} One of the select_one choices for this field is "Other." There is another (text) field within this same repeat named ${Species_Unlisted} with relevant = selected(${Species_Common}, 'Other').


When you say that you "move on to another repeat and then page back the relevant field", do you mean that you literally move on to another repeat, or that you move onto another instance within the same repeat, or do you mean that you have nested repeats?


Once you have entered text into the aforementioned ${Species_Unlisted} field and advance to a new record within that repeat, returning using the navigation buttons causes this text field to clear any previously entered text. This is not a nested repeat. 

And when you say that you "page back the relevant field", do you mean that you are altering the value of the field that determines the relevance of the text field?  Or that you are returning to a previous instance within the same repeat or that you are returning to a previous page within the same survey that also contains a repeat? 


The only action being taken by the user is using the repeat navigation buttons. The ${Species_Common} field, which determines the relevance of the ${Species_Unlisted} field is not being altered during this process.

I am assuming something is happening while navigating back to the record in question which causes the ${Species_Unlisted} field to become non-relevant briefly and thus it clears it's contents...but I'm not certain. 

Thanks again for your response.

-Dusty

0 Kudos
LaurenceTait
Occasional Contributor II

Thankfully the solution is really simple. Change your [relevant] field in row 33 from:

selected(${Species_Common}, 'Other')

to:

${Species_Common} = 'Other'

The problem is that "Selected"  reads from the most recent value held in the memory. As soon as you move onto a new instance, the selected answer becomes "null". The survey then reads that value from memory, and that recalculates all the data in all the "Unlisted_species" fields and sets them to "null",

If you use ${Field} = 'Value', it works off the value written in that instance. No danger of deleting.

Can I also make another suggestion?

Set [bind::esri:fieldType] for rows 32 and 33 to "Null". Then create another calculate type field with the [calculation] value of 

if((${Species_Common} = 'Other'), ${Species_Unlisted}, ${Species_Common})

That way you only have one field for the species common, rather than having the names split across two fields. Much easier to work with.

DustyJordan
New Contributor III

Hi Laurence,

Thanks for taking a look at my form.

This form actually had ${Species_Common} = 'Other' as the original [relevant] calculation on row 33. When I noticed this issue last week I changed it to: selected(${Species_Common}, 'Other') in hopes that it might fix the issue. Unfortunately, both relevant calculations/formulas cause this behavior. 

I'll look into your suggestion as well. Having the unlisted species in the same field as the species common name would be more convenient when handling the data later. 

 

0 Kudos
LaurenceTait
Occasional Contributor II

I just tried it with the suggested change and it works as expected. See below. 

The only other change I made was removing the required setting from row 32 (it refers to an external table that you didn't provide).

Try making the same change sat your end and letting us know how you go. 

 

LaurenceTait_0-1663039767793.png

LaurenceTait_1-1663039779088.png

 

LaurenceTait_2-1663039796518.pngLaurenceTait_3-1663039812462.png

 

0 Kudos
DustyJordan
New Contributor III

EDIT: See images below. I wonder if it's a version issue or something? I built this survey in January 2020 and it's been running with no issues until this, maybe something happened with a recent update? I'm running Connect version 3.14.256, if that matters. 

 

DustyJordan_0-1663040289085.png

DustyJordan_1-1663040311421.png

DustyJordan_2-1663040359247.png

DustyJordan_3-1663040391014.png

DustyJordan_4-1663040447361.png

 

 

 

0 Kudos
LaurenceTait
Occasional Contributor II

Well, that is just bizarre. You've discovered a serious bug.

The problem is being caused because the same formula is in both the [required] and [relevant] fields.

You can obtain the result you want by using any of the three following formulas:

regex(${Species_Common}, 'Other')

${Species_Common} = 'Other'

selected(${Species_Common}, 'Other')

You can put any formula into the [relevant] or [required] fields, and it works perfectly. And you have to have a formula in both fields.

But of you put any formula into both fields the problem you saw manifests.

That's a pretty serious bug you've discovered, and probably should be reported.

Anyway, there's a simple workaround for your purposes. Select any two different formulas and put them into the [required] and [relevant] fields respectively. Alternatively use the same formula, but put it into the [body::esri:visible field] instead of the [relevant] field.

DustyJordan
New Contributor III

Putting different formulas into the [required] and [relevant] columns does seem to have solved this issue. Thanks for your help in figuring that out Laurence! 

I've not reported a bug for Survey123 before, where/how should I go about doing that? 

 

0 Kudos