Hello.
I'm using Survey123 Connect to create survey that contains a 'cascading select'. A contractor must first select their company name and then select an active Work Order Number. The Work Order Number options are filtered by the company name. There may be cases where a company does not have any active Work Order numbers. In those cases, i'd like to display a note that gives some details on who to contact, etc.
I'm imagining that the 'relevant' filter for the note would be something like 'count number of options in work order number question = 0'. So far, i can't figure out how to do that in Survey123 Connect. Does a function like that exist?
thank you.
Solved! Go to Solution.
If I select an option that doesn't have any results (in your case, no Work Orders), the string-length of the JSON is 0. And if anything is returned, then the string-length is >0. Your note could be keyed to that calculation (e.g., calc_length, above).
I just made a very lazy CSV called B.csv which contained a few options and uploaded it to Portal (below). Essentially, you would just need to maintain a Feature Layer of Work Order Numbers.
You can use string-length() to count the characters in the search response and determine if it contains anything.
E.g., In the Relevant column: string-length(${my_search})=0
Hi @abureaux
Thanks for your suggestion, but it doesn't work as i need it to. It seems that your formula detects whether or not a value has been selected from the Work Order Number question. I need a formula that can detect whether there are any options available in the Work Order number question. Its possible that there are no options in the Work Order Number questions based on the filter value in place because of the previous question's (Company) answer (hopefully that makes sense!)
My apologies for the confusion. The above formula would work with search(), but not cascading selects.
There is no explicit formula for detecting the number of items returned through a choice filter. You would have to keep tabs on which contractors do not have any Work Order Numbers.
As an alternative, have you considered using a Dynamic Choice List?
I put together an example as proof of concept, but I have a server issue to deal with. I will try to post later.
If I select an option that doesn't have any results (in your case, no Work Orders), the string-length of the JSON is 0. And if anything is returned, then the string-length is >0. Your note could be keyed to that calculation (e.g., calc_length, above).
I just made a very lazy CSV called B.csv which contained a few options and uploaded it to Portal (below). Essentially, you would just need to maintain a Feature Layer of Work Order Numbers.
Hey @abureaux
Based on your suggestions I'm gonna take a deeper dive into this, but before i got lost in that I wanted to Thank You for your sharing your time and knowledge. I really appreciate it. I'll get back to you later with results from my fiddling around.
Hi @abureaux
It has been a fun adventure learning more about the search() functionality. Thank you for pointing me in that direction. Broadly speaking, I think your suggestion will work fine.
I am seeing two bits of functionality, though, that are a bit nettlesome.
Those two items aren't enough to prevent me from using the Search() functionality, but just troublesome enough to slightly irk me. Do you have any suggestions for making the Work Order Number list blank until, and only if, a company name is selected?
Using a Calculate as the value of the searchText worked perfectly. I didn't have as much good look changing out the autocomplete appearance for minimal. The app behaved the same regardless of that setting. But I'm calling this a victory for now and moving on to the next hurdle.
Thanks again for your help. It is super-appreciated!