In the last I have used Join() and html to create a list form a repeat using multi select on the final page of a survey as a summary. In my new survey I must hide the repeat, this prevents the Join() function from reaching more than the first value.
Is there a way to use concat() html on a repeat result to create a list. I realized it is already joined - like join() would do, but I need to insert the html.
Below is what I use to join() using my repeat:
concat('<li>',join("</li><li></li><li>",${repeatfield}),'</li>')
It may be do to wrapping it in the concat. Some functions do not like that. Try separating the join into its own field then use that field in the concat.
The function I mentioned works, but it works with a repeat.
I need to create a list using html from a value (multiselect) like Red,Yellow,Blue.
Then you would need to use selected-at probably. Pull out each value that way, then recombine using concat. I do this and write out the max possibilities. If it is blank just nothing shows. But this may give you trailing commas.
This code also gets the label vs the name. Seems like a lot of work just to add a comma though.
concat(jr:choice-name(selected-at(${Rash1},0), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},1), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},2), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},3), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},4), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},5), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},6), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},7), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},8), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},9), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},10), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},11), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},12), '${Rash1}'), ' - ', ${Q1UserNotes})
I do the HTML inside the repeat with concat() by formatting repeat item one at a time (record by record). Then, outside the repeat, I use join() on that calculate to join them all together.
This what I do but, in this case, I want to hide the repeat. The concat() function only seems to work if you manually navigate to the last repeat item. Do you know a way around this behavior?
The same is true for all calculates within repeats. Calculates will only trigger for the current repeat item, hence needing to cycle through the repeat to get all calculates to trigger.
How are things added to the repeat? Are you are loading the repeat data from the Inbox for instance? If so, there is no way to get calculates to trigger for past submissions (short of manually scrolling through). The only way that would work is using an indexed-repeat. In that case, you'd have calculates outside the repeat to pull the required data from each index of the repeat. This similar to what Doug described below with selected-at(), just for repeats. The format would be:
indexed-repeat(question, repeat, index number) | Returns the value from a specific question in a repeat record. For more information, see Repeats. | indexed-repeat(${room_no}, ${floor}, 3) |
Yes, you'd need one calculate per record. So, if you expect there to be 10-15 records, you'd need at least 15 calculates to pull from 15 records. You'd use concat() and if() statements to ensure that empty records are ignored. Also, yes, this is very static. If the number of repeat responses varies between 1 and 100, for example, you may be in for a rough time. In that case, I'd consider a JavaScript function (no, I don't have one that would do this -- but this is all I can think of if you needed something more robust).
The forms seem to have messed up. I tried replying to this comment, but my message ended up attached to the other thread... Rather than attempt to re-post, I'll just leave you with this note to scroll up/down to see my other comment (posted around the same time as this one).