Select to view content in your preferred language

Join all repeats into a multiline text box separated by new line in web app

799
2
Jump to solution
05-05-2023 10:39 AM
CoreyWilliamsESRIAccount
Occasional Contributor

Hello,

I am trying to accomplish separating my concatenated repeats on a new line in the Survey123 Web App.  I am able to accomplish this in Survey123 Connect using "\n" however not able to replicate it in Web App. I have tried "\n" and <br> both with no success.

CoreyWilliamsESRIAccount_0-1683308126445.png

CoreyWilliamsESRIAccount_1-1683308307032.png

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Why does the text need to be formatted in the form that way? There are lots of ways that you can redisplay responses in other formats like map popups and dashboards.

If it needs to be in the form, try using a custom JS function in your form, as this will allow you to reshape and combine strings with a lot more flexibility than the built in S123 functions.

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

Why does the text need to be formatted in the form that way? There are lots of ways that you can redisplay responses in other formats like map popups and dashboards.

If it needs to be in the form, try using a custom JS function in your form, as this will allow you to reshape and combine strings with a lot more flexibility than the built in S123 functions.

- Josh Carlson
Kendall County GIS
0 Kudos
CoreyWilliamsESRIAccount
Occasional Contributor

Hi Josh,

Thanks for this recommendation.  I am not an expert with javascript by any means and was hoping you could help me tweak this code to produce the expected results.  Currently I'm seeing the fields referenced as undefined and the line break not working.

Could it be this functionality is not available in the web app?
Extending Survey123 with Javacript 

Starting with ArcGIS Survey123 version 3.10, you can incorporate logic in your forms using custom JavaScript (JS) functions.

 

Here is the code:

// In your form field "bds_comm_concat", 
// use pulldata("@javascript","notes.js","getCommSummary",${bds_lead_communication})

function getCommSummary(rows) {

	var commSummary = "";
  
	for (var i = 0; i < rows.length; i++) {
	  commSummary +=
		rows[i].bds_comm_date_text +
		", " +
		rows[i].bds_comm_user +
		", " +
		rows[i].bds_comm_method +
		":<br>" +
		rows[i].bds_comm_summary +
		"<br>";
	}
  
	return commSummary;
}

 

0 Kudos