Constraint not being honored

745
4
Jump to solution
02-28-2021 03:05 PM
ShelbyZelonisRoberson
Occasional Contributor II

Hi -

I've built a survey in Connect (3.12) and I'm having trouble with one part of it. My end goal is to have the survey PREVENT submission if a geocoded address field (${matchaddress} is null. Seems easy right? I thought I could create a select_one yes/no ${validaddress} field, calculate it to be 'no' if ${matchaddress} is null and 'yes' if ${matchaddress} is not null, and put a constraint on this field so that it will not let the user submit a record if ${validaddress} = 'no', but it doesn't work. It lets me submit a record even if the matched address is null and validaddress is no. I've also tried various iterations of this using ${matchaddress} = null, since it should have the same result. No dice.

What's weird is that if I put ${matchaddress} = 'null' in the relevant column, the ${validaddress} field either shows or doesn't show exactly as it should. So why isn't the constraint working the same way? I've worked on this for days and days and I feel crazy and I'm really hoping someone on the Survey123 team can briefly work with me and take a look. I'd prefer to email my XLS rather than share here.

Thank you!

0 Kudos
1 Solution

Accepted Solutions
ShelbyZelonisRoberson
Occasional Contributor II

I played around a lot with this using both 'null' and '' as suggested by Doug.

The thing that finally worked:

1. Delete the validaddress field altogether - for some reason this seems to have been throwing it off

2. Set the constraint on matchaddress to be ${matchaddress}!='null' (also removed previous expression in the relevant column). I tried a constraint for ${matchaddress}!='', but the geocoder is indeed returning 'null'. 

View solution in original post

4 Replies
DougBrowning
MVP Notable Contributor

Have you tried required?  Constraints cannot test for blank '' since it could be a relevant hiding.  When a question is blank in 123 it gets '' not null.  Null is not used.

Hope that works.

0 Kudos
ShelbyZelonisRoberson
Occasional Contributor II

Yep I've tried required on a variety of the fields to try and get it to not allow submission but I haven't found a solution where it works properly. As for nulls... I'm not sure if the matchaddress question is coming up blank or truly "null" because it's reaching out to a geocoder, matching an address, and returning the matched address. If it doesn't find an address, I'm not sure what it comes back with. I assumed the matched address field was coming back as null when no address was found, because the relevant column ${matchaddress} = 'null' works as I expect it to.

I'll try playing around with '' - thanks!

0 Kudos
DougBrowning
MVP Notable Contributor

I have never used geocoder so not sure exactly what it returns.  Usually if I do not know I create a note or text field to show the value then I know exactly what it is.  Then test for that.

0 Kudos
ShelbyZelonisRoberson
Occasional Contributor II

I played around a lot with this using both 'null' and '' as suggested by Doug.

The thing that finally worked:

1. Delete the validaddress field altogether - for some reason this seems to have been throwing it off

2. Set the constraint on matchaddress to be ${matchaddress}!='null' (also removed previous expression in the relevant column). I tried a constraint for ${matchaddress}!='', but the geocoder is indeed returning 'null'.