Hello,
I am trying to do some conditional calculating. I have an address field in my survey and I'm using pulldata @layer to get the address of a parcel that the point is placed on.
If the point is not placed on a parcel, I'd like to return a piece of text like "No Address Found" or something.
My actual pulldata is working fine, I get addresses when the point is on a parcel, but I want to set a default value. From what I understand, actually using Default might not work because that only evaluates when the survey is opened, so if I click a point that isn't on an address, then the default is overwritten with nothing.
pulldata("@layer", "getValueAt", "attributes.ADDRESS", "<parcel REST endpoint>", ${EP311_point})
Solved! Go to Solution.
The example for if is:
if(selected(${question_one}, 'yes') and selected(${question_two}, 'yes'), 'yes', 'no')
So you'd want something like
if($raw='', 'No Address Found', $raw)
Or to smash it all together:
if(pulldata("@layer", "getValueAt", "attributes.ADDRESS", "<parcel REST endpoint>", ${EP311_point})='', 'No Address Found', pulldata("@layer", "getValueAt", "attributes.ADDRESS", "<parcel REST endpoint>", ${EP311_point}))
Yuck. You come back to that in 6 months there is nothing you can do with it but pull it apart. That's a pain. Do future you a solid and try out the extra lines.
Also yeah, I do not like the XLSforms syntax, don't end up using it quite enough to ever fully feel comfortable with it, won't surprise me if it needs a little tweaking to work.
Break it out into two lines? Stash your pulldata result in a hidden question. Set the default to the same "" you get when it fails to return. Then on the next line, the address your going to display just use a if to look at that hidden.
Pretty sure you could also just nest your pulldata into the if but I like the readablity of more lines.
Ideally I'd avoid extra lines though I had thought of that option too - do you have an example of the nested If syntax? The Survey123 connect syntax turns me around sometimes.
The example for if is:
if(selected(${question_one}, 'yes') and selected(${question_two}, 'yes'), 'yes', 'no')
So you'd want something like
if($raw='', 'No Address Found', $raw)
Or to smash it all together:
if(pulldata("@layer", "getValueAt", "attributes.ADDRESS", "<parcel REST endpoint>", ${EP311_point})='', 'No Address Found', pulldata("@layer", "getValueAt", "attributes.ADDRESS", "<parcel REST endpoint>", ${EP311_point}))
Yuck. You come back to that in 6 months there is nothing you can do with it but pull it apart. That's a pain. Do future you a solid and try out the extra lines.
Also yeah, I do not like the XLSforms syntax, don't end up using it quite enough to ever fully feel comfortable with it, won't surprise me if it needs a little tweaking to work.
Yes, that is indeed cumbersome but with one minor tweak it does in fact work:
if(string-length(pulldata("@layer", "getValueAt", "attributes.ADDRESS", "https://gis.edenprairie.org/maps/rest/services/Public/Parcels/MapServer/0", ${EP311_point})>0),'No Address Found',pulldata("@layer", "getValueAt", "attributes.ADDRESS", "https://gis.edenprairie.org/maps/rest/services/Public/Parcels/MapServer/0", ${EP311_point}))
For some reason the empty quotes didn't get it done, but comparing against the return string length did the trick.