Select to view content in your preferred language

If statement on text question in Feature Report Survey123

1784
6
09-18-2020 07:46 AM
PeterGoedbloed
Emerging Contributor

Hi, 

I have been struggling with If statements in feature reports. 

Is it possible to make a statement based on whether a text question is answered? I tried among other thing this expression, but it doesn't work: 

${if (OPLP1_oms string-length>0)}    

${/}

 

In which 'OPLP1_oms' is the text question.

Please advise.

0 Kudos
6 Replies
DougBrowning
MVP Esteemed Contributor

if(string-length(${OPLP1_oms}) >0, if true goes here, if false goes here)

In general it is

if(statement, true, false)

${feild name}

functions are function(field)

Hope that helps.  Looking at the sample in the help will be a good place to get started.    Big note is that feature reports may act a bit different.

0 Kudos
PeterGoedbloed
Emerging Contributor

Hi Doug,

Thanks for your comment.

I know that's usually the setup, but for if statements in Report templates it seems to work slightly different: Feature report templates—ArcGIS Survey123 | Documentation.

Under the header 'conditional elements' they use the following example expressions:

  • ${if photo1} displays the section only if the photo1 question has been answered.
  • ${if integer1>0} displays the section only if the answer to the integer1 question is a positive number.

You then close the expression with ${/}

0 Kudos
SSMGroup
Regular Contributor

Doug,

Is it possible to do an if statement like the one you listed above (string-length(${fieldname})>0), if true, check a box, and if false, do not check the box?

Thanks

0 Kudos
Vinzafy
Frequent 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

 

DerrickFreseADF
New Contributor

This helped me out, thanks for sharing @Vinzafy 

Vinzafy
Frequent Contributor

Awesome! Glad it helped 😊

0 Kudos