Select to view content in your preferred language

Creating a way to force user to return to repeats if condition not met

1524
5
Jump to solution
11-22-2017 02:25 PM
BonnieWeller1
New Contributor III

I have a series of questions embedded within a repeat that need to answered but since it is a road survey, the user has requested that they just capture a few pieces of information and then go back later (when safe to do so) and fill in the remaining questions that are in the repeat section.

One idea that I am working on is to create a question ("Continue") that asks the user if they want to continue entering the remaining species data. If they select "Yes" the remaining fields within the repeat section become visible. If not, they can add a new record without filling in the rest of the fields in the form, but I am trying to figure out a way to force them to go back and complete these fields before submitting the survey.

I thought that maybe I could count the number of times "Continue" equaled "No" and if it was > 0, the survey would not be validated (i.e. submitted). I tried to create an integer field with the following in it's calculation field "count(${Continue}='no')" but it complains about that. Even if I could get this formula to work, I am not sure how to get the validate/submit check mark to trigger "invalid" if it was greater than 0.

Does anyone have some suggestions as to how to solve this issue?

Any while I am at it, I forgot how and where to put the date and time conditions so that it would not reset to current date/time as I scroll through past records. Where I have it in the current form resets it.

Using Beta version 2.5.10. Many thanks.

0 Kudos
1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi Bonnie,

The count() function cannot take an evaluation like ${Continue}  = 'no' .  Instead, you should create a calculate value (with Esri:fieldType of null and bind::type column set to integer) that has the evaluation in an if() statement to give it a value of 1 if no, 0 otherwise:

if(${Continue}  = 'no', 1, 0)

and then use the count() function on that question.

View solution in original post

5 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Bonnie,

The count() function cannot take an evaluation like ${Continue}  = 'no' .  Instead, you should create a calculate value (with Esri:fieldType of null and bind::type column set to integer) that has the evaluation in an if() statement to give it a value of 1 if no, 0 otherwise:

if(${Continue}  = 'no', 1, 0)

and then use the count() function on that question.

BonnieWeller1
New Contributor III

Thank you James. I needed to use the sum function though. And after an initial misstep I realized I had to put the field with the calculation if(${Continue}  = 'no', 1, 0)inside the repeat section instead of the summary section. After that it I got the CompleteCount field to tally only the 'no' selections for CompleteNo field. BTW, wasn't sure where the bind::type column was but I assumed it was the column simply labelled "Type". If not, let me know.

So now I have a field (CompleteCount) that sums on the CompleteNo field (if statement field). How do I set things up so that it will not allow me to submit data if CompleteCount > 0?

Can you remind me how to do the time/day to not automatically update when I return to the record? You told me how to do it better in the workshop I attended last month but cannot find seem to find my notes. Was it that I had to put it in the default column instead of the calculation column?

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Yes, you're right the sum() function is the one to use.  the bind::type column  controls how the question value is handled inside the form; by default calculate questions are text, so sum() will concatenate them together. You will need to add a column called bind::type to the XLSForm.  I've attached a sample from the workshop that uses this pattern (look at lines 16-17 & 21).

0 Kudos
JamesTedrick
Esri Esteemed Contributor

ON time/date, you would provide the value now() in the default column - that will prevent the value from updating when reopening the survey.

BonnieWeller1
New Contributor III

I am beginning to think that although I am able to create a count of records within a repeat, I cannot set it up so that when I select Validate/Submit, the data won't get submitted if the CompleteCount > 0. The field CompleteCount can be greater than 0 until I go to submit the data, then it cannot. As far as can tell there is no way to set a condition only when Submit is selected. So, actually the answer to this post "Creating a way to force user to return to repeats if condition not met" is "You can't". Correct?

0 Kudos