Use constraint on location to prevent default loc from being accepted?

426
9
02-04-2019 04:38 PM
Highlighted
Occasional Contributor

I have several Survey123 webforms where the default location (under Detailed Map > Home Location in Connect) is set to be the center of Washington state. However, this is really just to center the map on the state to visually indicate to the user that they can specify a location anywhere in the state. Especially in cases where the user submits a wildlife observation back at home on their PC (instead of at the time of obs on their phone), some users have not been entering in the actual observation location and instead just skip to the next question before submitting their report. This geopoint field is required but since there is a default location the form accepts their non-answer. I was wondering if it was possible to set a constraint to prevent this? For example change the default to unrealistically precise (e.g. DD to 7 digits to right of decimal) and then use constraint field to not allow this location. If so, how would this formula look in the constraints field for the geopoint? 

BTW: I know constraints aren't currently working correctly in webforms (or rather the message around constraints) but it sounds like this initial problem will be resolved with next version at the end of February. (Constraint message in Web Form persists during correct answer)

9 Replies
Highlighted
Esri Frequent Contributor

Hi Treg,  This blog post by Michael Kelly‌ may be of good use for your scenario. https://community.esri.com/groups/survey123/blog/2017/10/26/limiting-extent-in-which-input-point-can...  I have not personally tried this in a web form, but I thought I would share  in case it gives you some ideas.

Reply
0 Kudos
Highlighted
Occasional Contributor

Excellent post by Michael Kelly but for the web version of Survey123 I don't think this will work...unless you're planning on extending the limited pulldata functionality in the web version to geopoint questions soon?

Might there be another workaround that requires the observer to do something with the map control (pan, zoom,etc) in order to show "success" on this required field? Because I'm centering the map in Connect, the default center location is being used to fulfill the "required" condition and the user isn't forced to make changes to this location before submitting.

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Treg,

The pulldata('@geopoint', ...) function works in the web form.  

With regard to requesting the user's location, this was recently added for surveys authored initially in the web designer as part of 3.2 - we will work to make this setting available to forms published from Survey123 Connect.

Reply
0 Kudos
Highlighted
Occasional Contributor

Thanks James, I'm glad to know that pulldata('@geopoint', ...) function now works in webforms. However, I think I need to wait to implement for two reasons:

  • For the 'constraint message' issue to get resolved at the end of this month.
  • And more importantly, the constraint doesn't seem to work on a hidden field (in the webform version). I just posted about this in Michael's post , (so sorry for the cross-posting!)
Reply
0 Kudos
Highlighted
Occasional Contributor

Update: A workaround for constraining geographic extent in a web form is described at the end of Michael Kelly's post:https://community.esri.com/groups/survey123/blog/2017/10/26/limiting-extent-in-which-input-point-can...

However, the workaround uses a Note field rather than a hidden field. While this works well enough to deliver an error message to user after they have selected a location, this is not a very good option for preventing the default location from being used by the user to submit a record because the warning will show right away.

Are they any plans by the webform team to allow constraints to fire from a hidden field?

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Treg,

We initially reviewed whether constraint checking was needed a couple of years ago.  At the time, the thinking was that  it should be possible to apply the constraint to a visible field.  Is there a reason the constraint could not be applied to the geopoint question?

Reply
0 Kudos
Highlighted
Occasional Contributor

Good point James...last year when we were encountering the constraint message issue in webforms, I did try applying the constraint to the geopoint question. I wasn't successful but I didn't put in very much effort either because I was focused on the issue with constraint messages. I'll try this again soon but if you have any available examples (or an Ismael-like blogpost?) of constraining a geopoint, that would be helpful.

Reply
0 Kudos
Highlighted
Occasional Contributor II

Rather than a constraint, I've thought it would work well if the location were null when the form loads. Then the location is not populated until the user sets it. Hopefully, setting the geopoint to required would then force the user to pick a location.

Required doesn't work right now because it always loads a default (bad) location. I've seen this cause lots of problems.

Reply
0 Kudos
Highlighted
Occasional Contributor

Jimmy is right in that, if "Required" setting on GeoPoint was working as expected (i.e. user must interact with the map and select any location), then I wouldn't need to apply a constraint to the geopoint question in order to prevent the default, state center location from being accepted.

Reply
0 Kudos