I'm wondering why my custom JS function to concatenate attributes of a repeat is working when I test in survey123 connect, but does not work when I open in the web app. I am attaching my function, as well as screenshots of the connect example and what happens in the web app. The calculation for the readonly question is:
pulldata("@javascript","functions.js","teamRepeatFunction",${project_team}) |
The survey is not public, and is currently only shared with the owner.
/*
* JavaScript functions for Survey123
*/
function teamRepeatFunction(teamrepeat) {
var teamlist = "";
var i;
for (i = 0; i < teamrepeat.length; i++) {
teamlist = teamlist + teamrepeat[i].team_member_name+": " + teamrepeat[i].team_member_role + ", ";
}
return teamlist;
}
Solved! Go to Solution.
Without knowing exactly how your form is working you should be able to do this without the javascript function.
Inside the repeat add a field and use a concat function: name: teamlist calculation: concat(${teammember_name},': ',${teammember_role}) This could be hidden and a null type field if you don't need to capture it.
outside the repeat: name: teamlist_join, calculation: join(', ',${teamlist})
Make sure the field length outside the repeat has enough characters not to throw any errors, up it to like 1000 or more depending on your expectations of how long the "teamlist" could get.
Without knowing exactly how your form is working you should be able to do this without the javascript function.
Inside the repeat add a field and use a concat function: name: teamlist calculation: concat(${teammember_name},': ',${teammember_role}) This could be hidden and a null type field if you don't need to capture it.
outside the repeat: name: teamlist_join, calculation: join(', ',${teamlist})
Make sure the field length outside the repeat has enough characters not to throw any errors, up it to like 1000 or more depending on your expectations of how long the "teamlist" could get.