Constraint to match values of string fields, with warning before validation

1423
2
Jump to solution
05-11-2021 04:32 PM
JulietK
Occasional Contributor II

Hi, I am wanting to ensure users are entering their data only while logged into their own account, and not someone elses. 

I have a username field to pull the username (field 'USERNAME'). I have a select_one field ('SUBMITTER') of the list of usernames, for the submitter to select their own name from. 

I'm wanting to set the constraint of SUBMITTER field so that the survey cannot be submitted unless the values of the SUBMITTER and USERNAME match. I thought the answer would be to set a constraint like .=${USERNAME} for the SUBMITTER field, but I get a constraint message regardless of whether the two field values match or not (the choices list names and labels for the SUBMITTER field is in the same format as the USERNAME value automatically pulled from the fieldtype username). What is the correct syntax I should be using?

 

In addition to this, I would like to set up a warning in case of the fields not matching, so that the submitters find out about the constraint early on, and not at the end of the survey. Since the only way to meet the constraint is to log out and log back in as themselves, they would lose all the survey answers if they find the error at the end of the survey which is the only time the constraint message comes up. One option I found is to create a note field with a warning, and set the relevance so that the warning note only comes up when the two above fields DON'T match. What is the correct syntax for the relevant field for this?

 

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

Are you sure the list matches the username exactly?  Display it to make sure.  

This works fine for me.  Using a note with a relevant on it.  I use this for inline warnings a lot.

DougBrowning_2-1620833309201.png

 

DougBrowning_1-1620833163936.png

Hope that helps

View solution in original post

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

Are you sure the list matches the username exactly?  Display it to make sure.  

This works fine for me.  Using a note with a relevant on it.  I use this for inline warnings a lot.

DougBrowning_2-1620833309201.png

 

DougBrowning_1-1620833163936.png

Hope that helps

0 Kudos
JulietK
Occasional Contributor II

Hi Doug, 

Perfect, thank you for that! The values were definitely matching and I thought that was the correct syntax, so not sure why I was getting errors inconsistently yesterday. And the syntax for relevant is really helpful, thank you! 🙂 

0 Kudos