XLS Form: Not allowing duplicate entries for a field of a repeat group

Hi there,

I've got a repeat group in my form and I would like to ensure that one of
the questions inside will not accept the same value again when repeated.
Ideally I would like to use the current repeat count to populate the field.
Is there a way of counting which repeat I'm currently on and using that
number as part of an ID for a field inside the repeat group?

Any suggestions/useful links on this are much appreciated!

Thanks

Hi Korinna,

You can count the number of repeat you are on with position(..), but I
can't think of an easy way of using that count as part of the ID. Once
you are outside the repeat, you could probably use indexed-repeat
(https://opendatakit.org/help/form-design/binding/) to check for
duplicates and then warn the user then.

If I had this problem, I'd use a fixed number of questions instead of
repeats because it's so much easier to reason about.

Yaw

··· -- Need ODK consultants? Nafundi provides form design, server setup, in-field training, and software development for ODK. Go to https://nafundi.com to get started.

On Wed, Apr 20, 2016 at 1:12 AM, Korinna Pinakoulaki korinnapinakoulaki@universaldoctor.com wrote:

Hi there,

I've got a repeat group in my form and I would like to ensure that one of
the questions inside will not accept the same value again when repeated.
Ideally I would like to use the current repeat count to populate the field.
Is there a way of counting which repeat I'm currently on and using that
number as part of an ID for a field inside the repeat group?

Any suggestions/useful links on this are much appreciated!

Thanks

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

See this: https://opendatakit.org/help/form-design/#xpath_expressions

Doing this is generally tricky.

If your data-entry values are constrained so they do not contain embedded
spaces, you could use join(" ", ${repeatedfield}) to construct a
space-separated list of values.

The following should then work assuming the repeatgroup is immediately
enclosing repeatfield:

selected(join(" ", /path/to/repeatgroup[position(current()/..) !=
position(.)]/repeatedfield), .)

Where:

/path/to/repeatgroup[position(current()/..) != position(.)]/repeatedfield

takes all repeatfield values that are not from the current repeat of
the repeatgroup.

If you do allow spaces, I don't have a solution.

··· On Tue, May 3, 2016 at 11:32 PM, Yaw Anokwa wrote:

Hi Korinna,

You can count the number of repeat you are on with position(..), but I
can't think of an easy way of using that count as part of the ID. Once
you are outside the repeat, you could probably use indexed-repeat
(https://opendatakit.org/help/form-design/binding/) to check for
duplicates and then warn the user then.

If I had this problem, I'd use a fixed number of questions instead of
repeats because it's so much easier to reason about.

Yaw

Need ODK consultants? Nafundi provides form design, server setup,
in-field training, and software development for ODK. Go to
https://nafundi.com to get started.

On Wed, Apr 20, 2016 at 1:12 AM, Korinna Pinakoulaki korinnapinakoulaki@universaldoctor.com wrote:

Hi there,

I've got a repeat group in my form and I would like to ensure that one of
the questions inside will not accept the same value again when repeated.
Ideally I would like to use the current repeat count to populate the
field.
Is there a way of counting which repeat I'm currently on and using that
number as part of an ID for a field inside the repeat group?

Any suggestions/useful links on this are much appreciated!

Thanks

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Hello Mitch

Can you please send an example in xlsform of what you explained please?

Thanks

··· On Wednesday, May 4, 2016 at 8:28:43 PM UTC+4, Mitch Sundt wrote: > See this: https://opendatakit.org/help/form-design/#xpath_expressions > > > Doing this is generally tricky. > > > If your data-entry values are constrained so they do not contain embedded spaces, you could use join(" ", ${repeatedfield}) to construct a space-separated list of values. > > > The following should then work assuming the repeatgroup is immediately enclosing repeatfield: > > > selected(join(" ", /path/to/repeatgroup[position(current()/..) != position(.)]/repeatedfield), .) > > > Where: > > > /path/to/repeatgroup[position(current()/..) != position(.)]/repeatedfield > > > > takes all repeatfield values that are not from the current repeat of the repeatgroup. > > > If you do allow spaces, I don't have a solution. > > > > > On Tue, May 3, 2016 at 11:32 PM, Yaw Anokwa wrote: > Hi Korinna, > > > > You can count the number of repeat you are on with position(..), but I > > can't think of an easy way of using that count as part of the ID. Once > > you are outside the repeat, you could probably use indexed-repeat > > (https://opendatakit.org/help/form-design/binding/) to check for > > duplicates and then warn the user then. > > > > If I had this problem, I'd use a fixed number of questions instead of > > repeats because it's so much easier to reason about. > > > > Yaw > > -- > > Need ODK consultants? Nafundi provides form design, server setup, > > in-field training, and software development for ODK. Go to > > https://nafundi.com to get started. > > > > > > On Wed, Apr 20, 2016 at 1:12 AM, Korinna Pinakoulaki wrote: > > > Hi there, > > > > > > I've got a repeat group in my form and I would like to ensure that one of > > > the questions inside will not accept the same value again when repeated. > > > Ideally I would like to use the current repeat count to populate the field. > > > Is there a way of counting which repeat I'm currently on and using that > > > number as part of an ID for a field inside the repeat group? > > > > > > Any suggestions/useful links on this are much appreciated! > > > > > > Thanks > > > > > > -- > > > -- > > > Post: opend...@googlegroups.com > > > Unsubscribe: opendatakit...@googlegroups.com > > > Options: http://groups.google.com/group/opendatakit?hl=en > > > > > > --- > > > You received this message because you are subscribed to the Google Groups > > > "ODK Community" group. > > > To unsubscribe from this group and stop receiving emails from it, send an > > > email to opendatakit...@googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > -- > > Post: opend...@googlegroups.com > > Unsubscribe: opendatakit...@googlegroups.com > > Options: http://groups.google.com/group/opendatakit?hl=en > > > > --- > > You received this message because you are subscribed to the Google Groups "ODK Community" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > > > > > -- > > Mitch Sundt > Software Engineer > University of Washington > mitche...@gmail.com