0 votes

[copied from GT FB group]

When showing answers stored in collections to users, a comma appears (",") and I don't know why. If anyone can shed some light on this, it would be much appreciated!

I'm working on a program where users are asked to pick their answers from a checklist (*question; *type: checkbox). The user also has the option to type in their own things (adding things not in the checklist) in a separate question (*question).

Their answers from the checklist are saved as a collection (1), and their answers from the optional question are saved as a different collection (2).

Later in the program, I want to repeat the answers back to the user (i.e. show them the answers stored in the collection(s)). If they added anything for the optional question that means collections (1) and (2) will both be repeated to the user. If they didn't add anything for the optional question, only collection (1) will be repeated to them.

When repeating the answers back to users - simply by typing the name of the collection(s) in curly brackets "{}" in GT - a comma appears at the end of the last item of the collection when users DID NOT add anything for the optional question (if they added their own item(s) for the optional question, then no comma appears).

I don't know how to avoid this comma from appearing without removing the comma separating the two collections in the code (which I don't want to do, as that means no comma separating the last item of the collection (1) and the first item of the collection (2) when shown on screen).

Does anyone know how to get rid of this comma (in the event that no optional answers are added by the user) while still being able to show answers in this way?

image

image

 

 

by (5.8k points)

1 Answer

0 votes

I'd nest it in

*if: physicalCustomWarningSigns

or

*if: physicalCustomWarningSigns.size > 0

Depending on how you set it up.

Or you could use the .combine keyword to combine the lists (potentially into another list if you want to retain them as separate lists

image

This shows the user a list of all items in the collection; but only items that actually exist, and without the commas. It can be adapted for sub-collections as well.

 

by (5.8k points)
Welcome to Guidedtrack Q&A, where you can ask questions and receive answers from other members of the community.
134 questions
144 answers
55 comments
40 users