Select to view content in your preferred language

Can relevant field be dependent on if condition IS NOT NULL

20080
7
Jump to solution
12-12-2016 07:59 AM
CarlHolt1
Frequent Contributor

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
IsmaelChivite
Esri Notable 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
IsmaelChivite
Esri Notable Contributor

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

CarlHolt1
Frequent Contributor

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.

0 Kudos
DanielMcIlroy
Frequent 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!

0 Kudos
JamesTedrick
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.

AndrewHargreaves2
Deactivated User

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

0 Kudos
JamesTedrick
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.   

AndrewHargreaves2
Deactivated User

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

0 Kudos