Prevent blank values in repeat integer field

1007
3
03-01-2018 04:22 PM
ChuckFarr
New Contributor

This seems like such an easy problem, yet I am having difficulty finding a solution. I have a repeat section containing an integer text box. I would like to prevent the user from adding additional repeat groups until they have entered data into the first.

I have attempted string-length(.)!=NULL, string-length(.)!=0, and string-length(.)!=-1 in the constraint section of the integer field. I have also tried .!=0 and .!=NULL. Nothing seems to work.

Any suggestions for this simple problem?

0 Kudos
3 Replies
by Anonymous User
Not applicable

Hi Chuck,

How about making the integer field required? If it is required, the user will not be able to add another record to the repeat, unless all required fields in the active record have been completed.

Phil.

0 Kudos
ChuckFarr
New Contributor

Hi Phil,

Thank you for the suggestion. We can't make the integer field required because sometimes the information in repeater will not be necessary. We would simply like to prevent the user from adding new information until they have entered text into an existing textbox.

As it stands, you can create a repeat with a textbox and continually press the plus button to add as many sections as you want, even if every single one is blank. 

Thank you again,

0 Kudos
by Anonymous User
Not applicable

Hi Chuck,

The ability to add additional records in a repeat without the need to fill in any data entry boxes of the first repeat is by design. There are workflows and scenarios where the repeat only uses calculations, geopoint questions, pulldata(), hidden fields etc, and therefore the user may not need to enter any data manually.

However, I believe there is a few options you can try to stop the user adding a new record to repeat without data in the fields in the first record:

Option 1: User the repeat_count option and set as relevant based on prior question to the repeat to set how many records the user requires. If they enter 0, then the repeat section (and questions) will not be displayed. If they need 3 records in the repeat, they enter 3 and the repeat section is populated with 3 records.

Option 2: Add an extra select_one question with a yes_no option at the end of the set of repeat questions, make it required when all other questions are null, make it relevant (visible) only when all other questions are null and also make it have an esri field type of null. By making it a null field type, the field will not be created in feature service, and will only be used in the app (the answer is not stored anywhere). This means if user has not entered any data in any of the repeat fields, there will be yes no question to ask "are you sure you want to create another record in this repeat?" or similar. It will not stop them doing it, but will force them to select yes or no, which in case will question why they are adding a new record. If they have entered data in the repeat fields, then they will not see this question and it will not be required, therefore they can just create a new record in repeat as normal.

Hope this helps.

Phil.

0 Kudos