Select to view content in your preferred language

Creating a constraint override

274
6
Jump to solution
a month ago
ZoieLowery
Emerging Contributor

I have a survey in Survey123 Connect. One of the questions asks for a meter reading value. The constraint on this value is that it must be higher than the previously entered readings for that specific meter. 

I used the pulldata() function here and it is working properly. 

However, there are a select few cases in which the new reading may not be higher than a previous reading. 

Is there a way to input some sort of manual override to the constraint? What I'm picturing is that when the constraint error message pops up, there is some sort of option for "override constriant, value entered is correct' or something. 

Any ideas are much appreciated!

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

mm I have had issues with numbers not liking "".    (Note . just means the current field.  It is just short hand.

Try this.

(${reading} > ${lastreading}) or (string-length(${override}) > 0)

View solution in original post

0 Kudos
6 Replies
RyanUthoff
MVP Regular Contributor

I'm not aware of any overrides to constraints. But, I think you could probably get creative with it. You might be able to keep your question as is, but incorporate an override value into the constraint itself. And then that would open up a new question for you to enter the "correct" value. It would be something like this:

  1. User inputs a value less than the previous meter reading value.
  2. Constraint catches it and displays a message saying that the entered reading is lower than the previous reading. Either correct your reading, or enter the manual override value (for example, they could type in 0) to override the constraint. Note that you would need to modify your constraint to accept the override value.
  3. Then, you would have a secondary question appear that is required based on the override value from your previous question where you ask the user to enter the meter reading value.
  4. From there, you can do some additional calculations if necessary so your "final" meter reading value is in a single column, instead of potentially mixed in two columns (one column for the initial meter reading value, and another column for the overridden meter reading value).

That's a potential workflow that might work. It's the best idea that I have, but it might be overly complicated compared to some other ideas people might have.

0 Kudos
DougBrowning
MVP Esteemed Contributor

You can add a or to your constraint that links to a override field.  Something like new > old or override != "" - have the override field relevant if new < old.

I tend to use a note field with a font color red and big font Warning that pops up.  Then have a question appear asking why they had to override.  Constraint that override field cannot be blank.  That way they have a huge warning they are under the old value and must consciously select a reason why.  Some crews still skip our huge red warning but that is users for you.

0 Kudos
ZoieLowery
Emerging Contributor

I think this is a good way to go about this. However, when I tried to write out this constraint it seems it's not working. This is what I have. It may be a simple syntax error; I am still new to this. I have seen periods in other constraints before, but I'm not sure what this actually signifies. Any idea whats wrong?

${reading} > ${lastreading} or ${override} != ''

'reading' is the user inputted reading
'lastreading' is the most recent reading on that specific meter
'override' is a field I created for users to input whether or not to manually override the constraint.

However, I am able to send the survey even if the override field is blank and the new reading is less than the old reading, so it's almost as if it isn't reading my constraint at all

0 Kudos
DougBrowning
MVP Esteemed Contributor

mm I have had issues with numbers not liking "".    (Note . just means the current field.  It is just short hand.

Try this.

(${reading} > ${lastreading}) or (string-length(${override}) > 0)

0 Kudos
ZoieLowery
Emerging Contributor

I think that worked! Thank you so much!

 

Neal-Kittelson
Frequent Contributor

You can use if statements in constraint fields, so if you have questions that indicate when  conditions where are lower reading would be acceptable, then use that to build it into the constraint.  I am guessing a new meter installed would be one of those:   If (selected(${visit},"NewMeter"), Constraint1, Constraint2).

0 Kudos