How do I only show Image section if an image is taken?

1416
5
Jump to solution
10-31-2019 08:58 PM
BenVan_Kesteren1
Occasional Contributor III

A user submits a survey via Survey123 app, and they can optionally take a photo if they like, I would like to show/hide the image section of my report based on wether a photo was taken. So if they only take two photos, only show the first two image tags, hide the rest.

It's currently setup like this:

I did read in another post that I should be using something like ${if photo1} but I have no idea how to implement that above, I have tried several variations and none have worked. Could someone please show me how to write the below two lines so that they are only included in my Survey123 Report if a photo was taken?

Image

${weed_image01 | size:500:0}

Thanks for your time.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
BenVan_Kesteren1
Occasional Contributor III

I am a goose! I have been looking for an error in the wrong places... I need to add a dollar sign to the close brackets. 

This is the correct code I should have been using:

${if weed_image04}${weed_image04 | size:500:0}${/}

Thanks very much for your assistance

View solution in original post

0 Kudos
5 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Ben, 

You can create a conditional section to only show information if a condition (such as if a photo is taken) is met.  See Feature report templates—Survey123 for ArcGIS | Documentation for information.

0 Kudos
BenVan_Kesteren1
Occasional Contributor III

Hey James, thanks for the reply. I should have mentioned in my OP that I had tried the following, both of them failed:

Image

${if weed_image01}${weed_image01 | size:500:0}{/}

Image

${if weed_image01 | size:500:0}

Image

${if weed_image01}

I am basically asking if anyone can correct my code that I am attempting to use? I have found the documentation is not very clear with this stuff (lacking full examples).

Cheers

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Ben,

The first entry is the pattern that should work - the if statement is evaluated and if true, the contents inside are displayed.  Just to check, the questions were named 'weed_image01' in the form (a double-check against the xlsx file)?

0 Kudos
BenVan_Kesteren1
Occasional Contributor III

Hey, 

So I have added the code as described, to my template docx:

${if weed_image01}${weed_image01 | size:500:0}{/}

${if weed_image02}${weed_image02 | size:500:0}{/}

${if weed_image03}${weed_image03 | size:500:0}{/}

${if weed_image04}${weed_image04 | size:500:0}{/}

${if weed_image05}${weed_image05 | size:500:0}{/}

And I get this warning when I upload the template to they survey123 page:

Error:

The tag beginning with "}{/" is unopened.

The tag beginning with "}{/" is unopened.

The tag beginning with "}{/" is unopened.

The tag beginning with "}{/" is unopened.

The tag beginning with "}{/" is unopened.

The loop with tag "true" is unclosed.

The loop with tag "true" is unclosed.

The loop with tag "true" is unclosed.

The loop with tag "true" is unclosed.

The loop with tag "true" is unclosed.

Any ideas what I am doing wrong?

I have confirmed the field names weed_image0X are correct.

Cheers

0 Kudos
BenVan_Kesteren1
Occasional Contributor III

I am a goose! I have been looking for an error in the wrong places... I need to add a dollar sign to the close brackets. 

This is the correct code I should have been using:

${if weed_image04}${weed_image04 | size:500:0}${/}

Thanks very much for your assistance

0 Kudos