Hello,
I'm looking to filter photos taken in the field and selectively put some of them into a report. Right now, photos are acquired in a repeat, and a select_one question also in the repeat has the user select from a few different types (overall, problem, and extra). See the photo below for a look at what's going on in excel. I've filled out a fake survey with three pictures that are "labeled" with the select_one question, one for each category in the same order as listed. In the report template at the moment, I'm trying to get just the photo that was labeled "overall" to show up. Code is as below:
${#photoRepeat}
${if ((photo_type) == “overall”)}
${photo|size:466.9:350}
${/}
${/photoRepeat}
No errors, but no matter what category the if statement is looking for it will print out all three photos. When it first printed all three, it was looking for the "overall" category, which was with the first picture. I tried changing the category to "extra" (the last picture) but still got all three photos, so it almost seems to me like the "${photo|size:466.9:350}" line is just spitting all three photos out. I'd love some thoughts on whether this endeavor is possible / where I'm going wrong if it is.
Thanks!
Marlene McGraw
EDIT: I'm going to put the solution here just so it's all clear if anyone needs to reference this in the future; for checking these values, you actually need to see if it matches the label name, not the data field name. In this case, my data field name was "overall" vs my label "Overall", so the capitalized version worked. Jim Moore also made a great point that my syntax here is wrong too - you'd want it to look like so: ${if photo_type == "Overall"}.
Solved! Go to Solution.
Well, good find on your part! That's definitely interesting that it references the label - and a smart move on your part to make sure it would always work. I've normally had my labels and names separate so I don't get them mixed up in other instances, but I may just have to keep them identical to keep this from happening in the future.
Hi Marlene & Chris
Good catch Christopher L. Rogers!
Just as some additional info, you can reference the choice name (as opposed to the label) by using getValue, which would look like this:
${if (photo_type | getValue:"")=="overall"}
Please note that in a future release we intend to update the syntax to make it simpler, so that the name is referenced in the conditional statement rather than the label; in which case the original ${if photo_type=="overall"} will then work. Note that the getValue syntax will also continue to work following this change. We'll endeavour to keep this thread posted with any progress.
Jim
Hi Marlene McGraw & Christopher L. Rogers
Just following up on this one: the 3.6 release has the syntax change as mentioned in my comment above.
So for a select question, the following expression will evaluate the raw value (i.e. the name) for that choice:
${if fruit=="banana"}Banana is selected.${/}
The choice's label can be referenced using getValue. For example:
${if (fruit | getValue:"label")=="Banana"}Banana is selected.${/}
Best,
Jim