Conditional Constraint Not Working as Expected

617
2
Jump to solution
12-20-2022 01:07 PM
LouiseHahn_GIS
New Contributor II

I have built a survey to track work performed for a group within an organization.  Initially, the survey required that the information entered must equal at least 8 hours of work; however, since this group often participates in overtime work, this constraint was not workable in all scenarios.  To account for situations where work is completed outside of the normal workday, and may acceptably not be 8 hours, I added another question to the survey to distinguish overtime events from normal workday events.  I then modified my initial constraint to the following:

if(selected(${OvertimeEvent},'no'), (${TotalHours}>=8), '')

The survey validates with no errors but fails operationally.  When I indicate 'yes' for an Overtime Event and enter a value less than 8 hours, I am unable to submit the survey.

How can I modify the survey so that I am able to submit when my total hours are less than 8 only if I have indicated it is an overtime event?

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

Since TotalHours is a note field 123 will treat it as text in the form.  Set bind::type to int or decimal and see if that does it.

Also I think constraint needs a true but '' is false so do this since 1 is a true.  

if(selected(${OvertimeEvent},'no'), ${TotalHours} >= 8, 1)

hope that does it

View solution in original post

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

Since TotalHours is a note field 123 will treat it as text in the form.  Set bind::type to int or decimal and see if that does it.

Also I think constraint needs a true but '' is false so do this since 1 is a true.  

if(selected(${OvertimeEvent},'no'), ${TotalHours} >= 8, 1)

hope that does it

0 Kudos
LouiseHahn_GIS
New Contributor II

Doug!!  That did it!  After testing, the setting of the bind::type didn't seem to make a difference.  I just needed to use 1 as my if false value instead of ''.

 

Thank you for your help!  And so quickly!