Constraint text formula stops functioning when hidden

917
7
Jump to solution
09-26-2022 11:01 AM
MAlfu
by
New Contributor II

Hello everyone,

Long-time community user, first time posing a question here. I'm working on a survey that will utilize a constraint formula within a repeat to prevent duplicate values from being selected in a select_one question. The values being stored are text codes (i.e. WEAT for Weather, POWR for power failure, etc.). I've tailored a constraint formula from other posts (shout out to Doug) to prevent duplicate responses from being submitted within the repeat. To account for the optional "additional hazards" choice, I added an exemption for that stored value. The formula is: 

not(contains(substr(${hazard_duplicate}, 0, string-length(${hazard_duplicate}) - 2), ${hazard_type})) or contains(${hazard_type}, "ADD")

I've been testing the formula within Connect with it visible as a "text" field and it works as intended. I want the field to be hidden from respondents now that it's working. When I try to hide the field though, the constraint no longer functions and duplicates can be submitted. I've tried changing the field type from text to hidden, leaving it as a text field with a hidden appearance and changing it to field type note with a hidden appearance. None of these options allowed the constraint to function while hidden. I also tried changing the bind::type and bind::esri:fieldType to string and that did not work while the field was hidden either. Will this formula not function when the value is set to hidden? When a field is set to hidden, is something added to the stored value that is preventing the formula from working? See the attached file for the survey. Any help would be greatly appreciated!

 

-Matt

1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

Correct I think I was the one that posted for them to remove the checks when a field is hidden.  The reason was if it does fire then it highlights a part of the form in red but there is no question there or it is the question above it I foget.  Makes it confusing on the user since it just sits there and no way to really fix it.

I just leave the list for the user so they can see what they all collected so far.  Does not seem to hurt anything just takes up a little space.  We made it a group and collapse it so it is out of the way.

Also note in some forms in the newer 123 I had to add a check for the first record.  It seems to load in a different order now.  I do not get it in all forms just some depending on relevants.  I also updated it to add the comma in the check.  We had some rare plant codes that broke it.  Like EAP was getting confused with EAP2. So now it checks for EAP,

New formula is weird to look at  Unknown is my exception

if(${TempCountUnk}=0, 1,${UnknownCode}='' or contains(${UnknownCode}, "XXXX") or not(contains(${AllUnknownCheck}+",",${UnknownCode}+",")))

Uses a temp count like this

DougBrowning_0-1664217441315.png

Other forms I can still use this but had to add a check for blank otherwise it fired too quick i think.

${Species}='' or contains(${Species}, "XXXX") or not(contains(substr(${AllPlantsCheck}, 0, string-length(${AllPlantsCheck}) - 3), ${Species}))

Hope that helps

View solution in original post

0 Kudos
7 Replies
DougBrowning
MVP Esteemed Contributor

Correct I think I was the one that posted for them to remove the checks when a field is hidden.  The reason was if it does fire then it highlights a part of the form in red but there is no question there or it is the question above it I foget.  Makes it confusing on the user since it just sits there and no way to really fix it.

I just leave the list for the user so they can see what they all collected so far.  Does not seem to hurt anything just takes up a little space.  We made it a group and collapse it so it is out of the way.

Also note in some forms in the newer 123 I had to add a check for the first record.  It seems to load in a different order now.  I do not get it in all forms just some depending on relevants.  I also updated it to add the comma in the check.  We had some rare plant codes that broke it.  Like EAP was getting confused with EAP2. So now it checks for EAP,

New formula is weird to look at  Unknown is my exception

if(${TempCountUnk}=0, 1,${UnknownCode}='' or contains(${UnknownCode}, "XXXX") or not(contains(${AllUnknownCheck}+",",${UnknownCode}+",")))

Uses a temp count like this

DougBrowning_0-1664217441315.png

Other forms I can still use this but had to add a check for blank otherwise it fired too quick i think.

${Species}='' or contains(${Species}, "XXXX") or not(contains(substr(${AllPlantsCheck}, 0, string-length(${AllPlantsCheck}) - 3), ${Species}))

Hope that helps

0 Kudos
abureaux
MVP Regular Contributor

Have you tried body::esri::visible rather than hidden?

0 Kudos
MAlfu
by
New Contributor II

I have not tried using the body::esri:visible field for hiding the duplicate check. I could not find much information on the field. From what I could tell, it seemed to be geared towards conditional visibility depending on how questions were answered.

I was able to get around the issue with @DougBrowning's suggestion of creating a separate group within the repeat for the duplicate check. Instead of a "duplicate check," it's now a collapsed, but selectable "hazards already assessed" for participants to reference. 

abureaux
MVP Regular Contributor

When you say "selectable" do you mean that the user can actually interact with the check? If this is being used for automatic duplicate detection, you may wish to make it read only so your users don't unintentionally modify it.

And yes, the new(ish) body::esri::visible is comparable to the older relevant column in functionality. The key difference is that items hidden by relevant cease to exist, while items hidden by body::esri::visible are just not visible (i.e., they can contain data, like calculates). As such, you can hide an item with it rather than the hidden column. I only suggested this as you mentioned that your field worked while it was visible, but not when it was hidden. body::esri::visible should maintain the same functionality as a visible field even if it's hidden.

0 Kudos
DougBrowning
MVP Esteemed Contributor

Well no - Both body::esri::visible and appearance of hidden do NOT fire the constraint so it does work different than a visible filed.  The reason is the UI gets wacky since there is no field to highlight in red.  I just tested it again.  

On the selectable thing you should the checking field a text list and make it really large if your repeat will get big.  Do not use a select for that.

0 Kudos
abureaux
MVP Regular Contributor

Ah sorry. Misunderstood. If the lack of a visible field to highlight highlight red is the issue, you can apply a constraint to a calculate as well. So converting the hidden text field into a calculate should work. I do this whenever I need to apply a constraint to a repeat. The constraint will work and the constraint popup will appear, but since it isn't tied to any physical point in the survey (like a text field), it may be confusing for users depending on how you have it set up.

0 Kudos
DougBrowning
MVP Esteemed Contributor

Wow calculate does work differently now.  It does a popup box in connect, not sure in the web or app.  This must be new.  It does seem like it would confuse the user though because it gives the name vs the label and that field is no where to be found.  I wonder if this popup will be added to hidden and visible.  

DougBrowning_0-1664312831648.png

For OP I think leaving the list viewable makes sense so the user can quickly see everything they added so far without scrolling through the repeats.

thanks

0 Kudos