Select to view content in your preferred language

Constraint not working on range type question populated from encoded URL

361
1
03-12-2024 12:02 AM
AngusWarfieldMc
Occasional Contributor

Hi, 

I'm trying to set up a simple constraint for a range type question in S123 Connect (v3.16.110).

The range question relates to a percentage of objective progress between 0-100, with the field name ${objective1_progress}. This has been set in the 'parameters' column as 'start=0 end=100 step=10'. It is being populated from an integer field in a hosted feature layer using an encoded URL in Field Maps, i.e.:

var url = 'arcgis-survey123://?itemID=...';
var obj1_prog = $feature["objective1_progress"];
url += '&field:objective1_progress=' + UrlEncode(obj1_prog);
return url;

Unlike text question types that are automatically populated by the encoded URL, the value for the range type question is only populated if I set the default column as the field name, i.e. ${objective1_progress}. Not sure if the integer values in my URL are being treated as a string and setting the default somehow circumvents this. 

This resolves the issue of populating the range type question. However, I need to apply a constraint where the minimum must be equal to or greater than the existing objective progress and less than or equal to 100. This is to stop users from accidentally decreasing the objective progress, when it should only increase. I have tried the following expression:

.>=${objective1_progress} and .<=100

I have also tried creating separate integer and range question types to store the value (with null fieldType), then used that field in the constraint, i.e.:

.>=${obj1_prog_int} and .<=100

.>=${obj1_prog_rng} and .<=100

In all cases, I am able to decrease the objective progress and submit the form without the constraint evaluating to False and preventing submission. 

What am I doing wrong?

 

 

0 Kudos
1 Reply
abureaux
MVP Frequent Contributor

Well, I'd start by updating Connect. There should be no reason to be using outdated software. Grab the MS Store version so it autoupdates.

I would definitely dump the value into both the visual field the ens user interacts with and a second field that you use for your constraints. Now, it seems like ranges and hidden fields for constraints both have their troubles. to bypass this, I propose two things:

  1. Make the hidden field (${obj1_prog_int}) visible and read only; and
  2. Add the constraint to the read only field

After that, you can apply the constraint to a different field. E.g.,

abureaux_3-1710255139500.png

abureaux_4-1710255148669.png

 

 

0 Kudos