Select to view content in your preferred language

Allow only 1 OR 0 in a Number field

248
6
10-02-2024 04:12 AM
CMcDonald
Frequent Contributor

Hello,

is it possible in ArcGIS Survey123 Web Designer to limit an entry in a Number field to 1 OR 0.

The constraint I have set below in example image still allows entries such as 00, 001 etc etc.

CMcDonald_0-1727867435181.png

Thanks

0 Kudos
6 Replies
CodyPatterson
Frequent Contributor

Hey @CMcDonald 

Here's a suggestion from another user in the solution, setting yes or no to 1 and 0, and then returning the number:
https://community.esri.com/t5/arcgis-survey123-questions/return-a-boolean-value-0-or-1-different-tha...

You would also be able to set regex inside of the XLSForm: regex(., '^(0|1)$')

This would restrict it to be 0 or 1 as requested.

Cody

0 Kudos
CMcDonald
Frequent Contributor

Hi @CodyPatterson unfortunately that solution is using Survey123 Connect, I don't use that.

0 Kudos
CodyPatterson
Frequent Contributor

Hey @CMcDonald 

Ah I see, sorry about that, instead, would it be possible to use radio buttons to create a choice question, I attempted this here and it returned only 1 or 0 depending on the choice:

CodyPatterson_0-1727868862992.png

This is a single select question:

CodyPatterson_1-1727868888228.png

 

Cody

0 Kudos
CMcDonald
Frequent Contributor

Hi @CodyPatterson Yes I tried this as it would be a slightly better solution but at the end of each section I have to perform a calculation i.e. Question1 + Question2 =

I could not get a calculation to work when the questions were of Single select type 😞

0 Kudos
CodyPatterson
Frequent Contributor

Hey @CMcDonald 

Ah alright I see, so you are wanting to create a sum of the answers then? If so, I would want to see what error you're facing, you may need to convert the question result to an integer, it may be coming over as a string and is not able to be added due to the types being different.

Cody

0 Kudos
CMcDonald
Frequent Contributor

Hi @CodyPatterson yes I think because I'm trying to add numbers from a text field it cannot work. Under the Calculation in the Number field using Number the question does not appear in the dropdown.

CMcDonald_0-1727874508551.png

The goal originally was to have Single select type questions with "Yes" and "No" entries. Yes would = 1 No would = 0.  However it didn't appear to be possible to tot up a total score in the Web Designer.  Hence my workaround of just using 1 and 0 now.

 

0 Kudos