Conditional Repeats

485
2
Jump to solution
04-13-2020 07:00 AM
YannickDelvaux
New Contributor II

I have a problem that I can's seem to work around in Survey123 Connect for ArcGIS.

I'm creating a pipeline inspection tool. First, the user is prompted to put in some general text and integer fields, giving information about the inspection itself. After that, the different testing points and inspection faults can be put in by using a repeat.

The user first has to select the type of point he's going to add (this is called an "Event" in my survey), and can then fill in the relevant fields, for that type of repeat. Let's say there are 4 kind of events a user can select, that all make certain fields within the repeat visible or invisible (this is a select_one drop down list):

1. Survey start point coordinates

2. Potential test point

3. All other event types ...

4. Survey end point coordinates

I get this part to work fine. However... when the user starts inputting events into the repeat, there should ideally be a few criteria to be met:

  • The first event/repeat can only be of the event type "Survey start point coordinates", and can only be selected once
  • The second event/repeat can only be of the event type "Potential test point"
  • All the following events/repeats can either be of the event type "Potential test point" or "All other event types" (in reality these consist of a bunch more event types, but trying to explain it simply)
  • The last event/repeat can only be of the event type "Survey end point coordinates", and can only be selected once

 

Since there is (i think?) no full proof way to get the index-number of the current repeat, I'm trying to work around it by adding calculated counters outside of the repeat, that calculate if each one of the event types have been used inside of the repeat (0 if it hasn't been used, 1 if it has already been used).

Now i can apply a choice_filter to my drop down, and pull the choices that i need into the select_one and display them.

Problems:

  • This works, but as soon as a user selects something in the event list, the counters that keep track of the used event types update their values, which also immediately applies new conditions to the filter used on the selection box, and updates it (which I don't want), which makes it impossible to work with
  • If a user adds a dozen events/repeats, but then goes back to the first repeat (of the event type "Survey start point coordinates") or any other repeat for that matter, and deletes it, there is no way to insert another repeat of the same type, at the beginning of the repeat sequence

Possible solution and it's problem:

A way to work around this problem, is to just ask for the values that are needed for "Survey Start point coordinates", "Survey End point coordinates" and the first "Potential Test point" outside of the repeat (since they are only needed once and in a particular part of the survey). That also keeps things much simpler configure inside of the repeat.

However, I don't want to separate these points from the rest of the data, table wise. I will eventually want to query trough resulting testing points, and I will need all events in 1 table, not 2 tables.

Any thoughts would be greatly appreciated.

Let me know if i didn't clarify enough.

Yannick

1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi Yannick,

It is possible to generate an internal count by having a function with count() inside the repeat refer to a question that will always be filled out in the repeat.  That being said, for a more complex validation like you have, it may also be appropriate to consider a custom JavaScript function, which is a feature currently in beta

View solution in original post

0 Kudos
2 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Yannick,

It is possible to generate an internal count by having a function with count() inside the repeat refer to a question that will always be filled out in the repeat.  That being said, for a more complex validation like you have, it may also be appropriate to consider a custom JavaScript function, which is a feature currently in beta

View solution in original post

0 Kudos
YannickDelvaux
New Contributor II

Hello James

Thank you for your answer. It seems that to solve this specific issue, i would have to look into a solution involving a custom JS Function. Because I did not have sufficient time for this project to explore it, i went with the workaround solution:

to just ask for the values that are needed for "Survey Start point coordinates", "Survey End point coordinates" and the first "Potential Test point" outside of the repeat (since they are only needed once and in a particular part of the survey)

I will definitely try JS as an alternative solution, whenever i have some time for the project again.

 

 

Sincerely

Yannick

0 Kudos