S123 web form: pre-fill multi-line textbox with setQuestionValue OR open=web

1001
6
09-30-2021 11:37 PM
Dawn
by
New Contributor II

Hi

Survey123Webform + setQuestionValue with multiline

We have a survey published from S123Connect with a multi-line textbox. The survey is opened in a Survey123Webform using setQuestionValue and the contents of the textbox are prefilled with text pulled from other data sources. 

survey123WebForm.setQuestionValue({
     comments: encodeURIComponent(this.comments),
});

where this.comments contains:

Test Entry 2\nB7 reports fire completely out.\nb50 reports fire out\nB15 reports that the fire is out.\nB10 reports the fire is out

 The earlier version published via S123C 3.9 definitely used to work as expected (multi-line contents displayed without additional encoding values. 

displayed correctly as:

Test Entry 2
B7 reports fire completely out.
b50 reports fire out
B15 reports that the fire is out.
B10 reports the fire is out

Now the same function encodeURIComponent(this.comments) when passing the data to the S123 textbox displays as:

Dawn_0-1633005028090.png

I am not sure when this behaviour changed as I have not looked at this specific survey for a while. Is there a workaround to get the linefeeds back into the displayed text?

If the multiline textbox is updated and the data is saved into the underlying feature service and the survey is re-opened in edit mode using globalid as a parameter, the lines are displayed correctly across multiple lines

If you do not use encodeURIComponent then only the first line of the question value appears. This is similar to the behaviour we have noticed with:

Web survey opened from link with field settings using encodeURIComponent 

https://survey123.arcgis.com/share/xxxxitemidxxxxx?portalUrl=https://domain.com/portal&open=web&fiel...These%20are%20the%20notes%20for%20this%20survey.There%20is%20more%20than%20one%20line%20of%20text&field:jobid=469&field:moduleid=1&field:location=8793%20Plein%20Street

In this scenario the text is cut off after line 1, but we do not see the html encoding characters

Dawn_0-1633069856402.png

 

 

0 Kudos
6 Replies
alison_gou
Esri Contributor

Hi @Dawn ,

Can you share a copy of setQuestionValue script? It does not have to be a whole copy, as long as it contains basic lines to reproduce your issue.

Regards,

Alison

0 Kudos
dstalberg1
New Contributor

Thanks Alison

this.callComments = "Line1: These are notes.\nLine2: And additional notes.\nLine 3: notes";
 
....
//*** 1 **** this returns the textbox containing the full character set from the URL request
survey123WebForm.setQuestionValue({
             call_comments: encodeURIComponent(this.callComments),
      });
 
//*** 2**** this cuts the incoming text after Line 1
survey123WebForm.setQuestionValue({
             call_comments: this.callComments,
      });
 
*** 1 ****
console.log(this.callComments);
dstalberg1_3-1634208453310.png
dstalberg1_0-1634205837444.png

 

*** 2 ****

console.log(encodeURIComponent(this.callComments));
dstalberg1_4-1634208529999.png

 

dstalberg1_1-1634206760126.png

 

These warning are also displayed in the log - do we need to change the way the Survey123Form is called and/or update to js api 4.21?

dstalberg1_2-1634207581438.png

0 Kudos
alison_gou
Esri Contributor

Hi @dstalberg1 ,

Can you try version lock as a workaround?

To complete version lock, two settings needed to be done:

1, Set for web app version lock. Go to website --click on the specific survey--settings--web app versions: use the version the survey was published with;

2, Set for js api version lock.  When referencing js api,  be specific about version as https://survey123.arcgis.com/api/jsapi/3.xx

 

Try if this would serve as your workaround.

Regards,

Alison

0 Kudos
Dawn
by
New Contributor II

Hi Alison

Thank you for the reply.

I take it that the workaround for the version lock only applies to the issue with the jsapi warning messages?

Do you have any feedback regarding the multiline textbox issue?

Thank you

Regards

Dawn

0 Kudos
alison_gou
Esri Contributor

Hi 

The version lock is for the multiline textbox issue, please have a try.

0 Kudos
alison_gou
Esri Contributor

Hi @Dawn 

We have an undergoing issue to support line break both in js api and url parameters.

The version lock is workaround for line break in js api.

Regards,

Alison

0 Kudos