Survey123 feature reports: conditional statement if a value has no answer (text)

2624
2
08-17-2020 08:39 AM
Marie-JoëlleDesgagné
New Contributor III

Hi,

I am trying to do a survey123 report template on word showing only questions with answers.

To show the phone numbers, I used this expression and it worked since the number 0 is written when we don't have the info: 

${if phone_number!=0}Phone number : ${phone_number} ${/}

For the email address it did not work since the answer is left blank when we don't know the answer:

${if email!=” ”}Email address : ${email} ${/}

Even though the email answer is blank, the title always shows up.

 

Anyone knows how to solve this?

0 Kudos
2 Replies
Jim-Moore
Esri Regular Contributor

Hi Marie-Joëlle Desgagné

To check if a question has an answer (i.e. is not empty), use the following syntax referring to the field name only (without any operators):

${if email}Email address: ${email}${/}

Please find more info here: Feature report templates—ArcGIS Survey123 | Documentation 

Best,

Jim

Vinzafy
Occasional Contributor

Hey there,

I realize this thread is three years old, but I was coming across the same issue and couldn't find a reliable answer.

Scenario

In a feature report, there is a text question. I want to return the inputs if the text question was answered, otherwise I want to add a custom message if no answer was provided.

Solution

We need to use the not equal (!) operator before the field name in a if statement.

Following that is the syntax for how you want to display the text if the question is answered.

E.g.,

 

 

${if !(note_question)}No notes were added for this question.${/}
${note_question| appearance:"multiline"}

 

 

If the text question is unanswered, the not equal if statement is true and the custom note is displayed. Though the note question is called, because it's blank, nothing will appear.

If the text question is answered, the not equal if statement is false, the custom note is not displayed, and the value submitted for the note question will display.

Result

Text question is unanswered; custom message appears

 

Vinzafy_3-1696616613870.png

 

Text question is answered; inputted value appears

Vinzafy_1-1696616553394.png