Select to view content in your preferred language

Character limit not working for text question in repeat

916
7
03-08-2023 11:32 AM
mzhang
by
Occasional Contributor

A couple users of a survey reported getting the "String or binary data would be truncated" error message when they tried to submit a response, and I realized it was probably because the text question within a repeat was not flagging responses longer than the field length. Is anyone else having this issue with text questions?

I'm using a web form published through Survey123 Connect 3.16 (and see the same bug in the 3.17 preview). The other text questions within the survey that are not in a repeat work fine. The question has a conditional requirement expression, but the issue persists even for a simple text question inside a repeat. I now have a constraint set for that question and added a note providing the count of characters left, but it would be nice if it could work as expected.

 

 

0 Kudos
7 Replies
Richard_Purkis
Esri Contributor

Hi @mzhang 

Thanks for raising this issue. Would you mind sharing an xlsx with the smallest reproducible issue and we can confirm if this is a BUG for you.

Thanks 

0 Kudos
mzhang
by
Occasional Contributor

Thanks Richard. Here's an xlsx where I cut out a lot of extraneous stuff from the actual survey. I noticed that the issue wasn't there when I first published without the "end" and hidden geopoint questions, but was present after I added those back in.

0 Kudos
AlisonOBrien
Esri Contributor

Hi @mzhang ,

The following bug was created for this issue:

  • BUG-000156030: The surveys do not provide a character count on text questions with repeats when viewing the survey from ArcGIS Survey123 in a web browser

There is a support article as well that provides a couple of workarounds: 

0 Kudos
mzhang
by
Occasional Contributor

Thank you for the update @AlisonOBrien.

If anyone else comes across this before the bug is fixed, my workaround (publishing in Survey123 Connect 3.16) was to try and recreate the normal behavior of questions with character limits, so the issue would be flagged before the user clicks Submit and a live character count would be provided. It's a more complicated, but makes it more clear to users what the issue is: 

  1. On the question with the bug (which was named "locationComment"), I put the constraint "string-length(.)<257" so it would be flagged immediately if the answer exceeds 256 characters, and set the constraint message to say, "Answer must be 256 characters or less." It should say "fewer," I know...
  2. Created a hidden note (named "locationCommentCharCount") that calculates how many characters the user has left before exceeding the limit. In the calculation field I put "256-(string-length(${locationComment}))"
  3. Created a regular note that would display "Characters left: " and pull the number calculated in the step 2. I put the following text in the hint of the question so that the font wouldn't be so large and bold: "<i>Characters left: ${locationCommentCharCount}</i>"

mzhang_1-1689613332564.png

 

Marc_Patti
Occasional Contributor

Hey mzhang, 

I managed to implement the constraint from your first step, and it ended up working great!

That said, I'm struggling to implement the character count you outlined in steps 2 & 3. If you have time, could you elaborate a bit more on how you managed to create that hidden note variable from step 2? I'm looking for a column that can hold a hidden note, but I'm not sure that  I see one.

Thanks for your time!

0 Kudos
mzhang
by
Occasional Contributor

Hi @Marc_Patti, I put type = note, appearance = hidden, and calculation = 256-(string-length(${locationComment}))

I hope that helps!

 

Marc_Patti
Occasional Contributor

Awesome, that totally fills in the gap for me. Thanks for your help!

0 Kudos