Can relevant field be dependent on if condition IS NOT NULL

6784
7
Jump to solution
12-12-2016 07:59 AM
Highlighted
Occasional Contributor III

Using a custom URL feature in Collector to allow users to open an inspection form in Survey123 from the feature needing to be inspected. Configured to have fields come over into text fields in Survey123, that the inspectors must answer. Using the revelant field, can I make those secondary fields dependent on if the primary(linked field) is not null?

Survey with Primary and Secondary fields

XLS Form

1 Solution

Accepted Solutions
Highlighted
Esri Frequent Contributor

Hi. Did you try adding something like string-length(${PrimaryQuestion})>0 into the Relevant column of your secondary question? 

View solution in original post

7 Replies
Highlighted
Esri Frequent Contributor

Hi. Did you try adding something like string-length(${PrimaryQuestion})>0 into the Relevant column of your secondary question? 

View solution in original post

Highlighted
Occasional Contributor III

See ichivite-esristaff‌ this is why ya'll are the best and so very helpful. I looked on XLSForm.org and other help docs. That worked. Thanks as always.

Reply
0 Kudos
Highlighted
Occasional Contributor

I'm having a similar problem, but with numbers rather than a string. I want to test to see if the user has missed field. This is different to it being a required field as the user will have the option to acknowledge that it is a valid NULL value.

JTedrick-esristaff‌ provided me some great advice on how to do the acknowledge, but the NULL test side of it has really got me chasing my tail!

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Dan, I replied in the original thread - the information on empty values is at Formulas—Survey123 for ArcGIS | ArcGIS - the string-length function also provides the null check for numerics.

Highlighted
Occasional Contributor III

James Tedrick

Can you supply an example of the syntax for 'NaN' within a constraint? I'm struggling to get it right. As you indicate above it's part of the string-length function. The documentation also states that "The NaN value compared to any other value will only be true in a calculation of an "is not equal" value comparison. All other expressions will result in false." As such, I came up with the below but it fails to trigger the constraint if {QUANTITY1} is left blank:

if(selected(${MATERIALS_USED}, 'YES'), string-length(${QUANTITY1})!=NaN, true())

Thanks

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Andrew,

The check for string-length is to compare it to 0 - the string-length function will return 0 for null or NaN values.  

string-length(${QUANTITY1}) > 0 

is true for non-NaN or null values, false otherwise.

The discussion on NaN/null you cite concerns understanding how those values affect calculations in other questions, not how to test for NaN/null.   

Reply
0 Kudos
Highlighted
Occasional Contributor III

Hmmm...struggling to wrap my head around this one. If I understand what you're saying:

  • {QUANTITY1} is an INT question and if left blank records as null. I want to prevent this and ensure there's always a number greater than 0 in there.
  • If "the string-length function will return 0 for null or NaN values" then I need to set my constraint to check the string-length for 0, and if true, fire the constraint message.
  • I use this expression to check that if the user has indicated they've used materials, they can't leave the quantity blank: 
if(selected(${MATERIALS_USED}, 'YES'), string-length(${QUANTITY1})!=0, true())
  • However, it fails to fire the constrain if {MATERIALS_USED} = 'YES' and {QUANTITY1} is left blank.

I've asked this in a similar thread here.

Thanks

Reply
0 Kudos