How to write "relevant" note for when field is left blank, but not required

622
6
04-23-2021 10:13 AM
DryCreekEng
Occasional Contributor

I created a survey form in the desktop version of Survey123 Connect for the collection of insect information in an apple orchard. My client needs the insect count field left blank to indicate that they did not check a trap; a 0 in the field would mean they checked the trap and found no insects.  If I set the field to required, a 0 is automatically populated in the field.  How do I write a note using the 'relevant' field to ask them if they are sure the insect count field should be null? So far I have tried:

${Codling_Moth_Male}=NaN

${Codling_Moth_Male}==NaN

${Codling_Moth_Male}=null

${Codling_Moth_Male}=<NULL>

The first one, ${Codling_Moth_Male}=NaN, lets the form run properly but does not provide a note when the field is left blank. 

Tags (2)
0 Kudos
6 Replies
PrachiPatel
New Contributor III

Maybe you could put the following text in the hint of the Codling_Moth_Male question "If trap unchecked leave blank, a 0 indicates trap is checked and 0 insects were found". 

OR

You could create a select_one field for "Have you checked the trap" (say the name is CHK) . If the answer selected is yes, by using the relevance field, the 'Codling_Moth_Male' question can appear else it wont appear and will remain blank. Relevance formula here could look like selected(${CHK}, 'yes')

0 Kudos
RandallCutting
New Contributor II

Have you tried?  ${Codling_Moth_Male}!=''

0 Kudos
RandallCutting
New Contributor II

Sorry, that would have been the opposite of what you're looking for.  Try:  ${Codling_Moth_Male}=''

0 Kudos
DougBrowning
MVP Notable Contributor

Blanks are tricking cause it is also considered false.

Also can try string-length(field) > 0 or = 0.

0 Kudos
DryCreekEng
Occasional Contributor

I did try this and it didnt work.  Thanks for the suggestion though. 

0 Kudos
DougBrowning
MVP Notable Contributor

So this is a int or decimal field?  I have a lot of trouble with those since comparing to "" really does not make sense.  I had given up.

But I just tried string-length(${testint}) < 1 and it did work for me.  and string-length(${testint}) = 0 also

But I just had and idea and it works also.  Convert to a string then test.

string(${testint}) = ""

If none of those work something else may be wrong.  Can you post your form?  Are you on 3.12?

0 Kudos