Auto-fill consecutively between groups?

Basically I'm trying to automatically fill fields consecutively between
groups.

Example:
Survey 1
Basic survey information (date, location, surveyor)
Plant data (start groups)
Plant 1 (group 1)
Plant type: A, B, or C* (manually select)*
Seed sample #: 3456* (auto fill)*
Plant 2 (group 2)
Plant type: A, B, or C* (manually select)*
Seed sample #: 3457* (auto fill)*
Plant 3 (group 3)
Plant type: A, B, or C* (manually select)*
Seed sample #: 3458* (auto fill)*
Plant 4 (group 4)
Plant type: A, B, or C* (manually select)*
Seed sample #: 1234 * (manually override, samples were not in
order)*
Plant 5 (group 5)
Plant type: A, B, or C* (manually select)*
Seed sample #: 1235* (auto fill)*
Plant 6 (group 6)
Plant type: A, B, or C* (manually select)*
Seed sample #: 1236* (auto fill)*
End survey

If anyone knows if this is possible and/or can simply point me in the right
direction, that'd be a huge help!
Thanks!

position() will tell you which repeat you are in. Take that number, do
whatever math or string manipulation (e.g., concat()) to get the
number you want.

Yaw

··· -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Mon, Mar 17, 2014 at 4:18 PM, havey dewlett hewlett.david@gmail.com wrote:

Basically I'm trying to automatically fill fields consecutively between
groups.

Example:
Survey 1
Basic survey information (date, location, surveyor)
Plant data (start groups)
Plant 1 (group 1)
Plant type: A, B, or C (manually select)
Seed sample #: 3456 (auto fill)
Plant 2 (group 2)
Plant type: A, B, or C (manually select)
Seed sample #: 3457 (auto fill)
Plant 3 (group 3)
Plant type: A, B, or C (manually select)
Seed sample #: 3458 (auto fill)
Plant 4 (group 4)
Plant type: A, B, or C (manually select)
Seed sample #: 1234 (manually override, samples were not in order)
Plant 5 (group 5)
Plant type: A, B, or C (manually select)
Seed sample #: 1235 (auto fill)
Plant 6 (group 6)
Plant type: A, B, or C (manually select)
Seed sample #: 1236 (auto fill)
End survey

If anyone knows if this is possible and/or can simply point me in the right
direction, that'd be a huge help!
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.

Havey,

Further break it down for me. I will and can be of help.
Plant types are select1 and when 1 is selected Seed sample should auto fill
(using acknowledgment ) a fixed integer figure or random, right?

··· On Tuesday, 18 March 2014 00:18:24 UTC+1, havey dewlett wrote: > > Basically I'm trying to automatically fill fields consecutively between > groups. > > Example: > Survey 1 > Basic survey information (date, location, surveyor) > Plant data (start groups) > Plant 1 (group 1) > Plant type: A, B, or C* (manually select)* > Seed sample #: *3456** (auto fill)* > Plant 2 (group 2) > Plant type: A, B, or C* (manually **select**)* > Seed sample #: *3457** (auto fill)* > Plant 3 (group 3) > Plant type: A, B, or C* (manually **select**)* > Seed sample #: *3458** (auto fill)* > Plant 4 (group 4) > Plant type: A, B, or C* (manually **select**)* > Seed sample #: *1234* * (manually override, samples were not in > order)* > Plant 5 (group 5) > Plant type: A, B, or C* (manually **select**)* > Seed sample #: *1235** (auto fill)* > Plant 6 (group 6) > Plant type: A, B, or C* (manually **select**)* > Seed sample #: *1236** (auto fill)* > End survey > > If anyone knows if this is possible and/or can simply point me in the > right direction, that'd be a huge help! > Thanks! >

Thanks everyone for your help! Here's what I've got.

Each plant group is set to auto-repeat, and the view is set as
"field-list". So all fields within the group are shown at once.
The "seed sample number" field is not dependent on the "plant type".

When each new "plant" group repeats I'd like the "seed sample number" to
auto-fill with +1 the previous plant's "seed sample number". The seed
sample number is an integer in this example. I'd also like to repeat
"select_one" and "text" fields based on previous entries, without +1 in
those examples.

I'd also like the value to be editable because the sample number
occasionally will be out of order. Which is what I tried to show here:
...
Plant 2 (group 2)
Plant type: A, B, or C* (manually select)*
Seed sample #: 3457* (auto fill)*
Plant 3 (group 3)
Plant type: A, B, or C* (manually select)*
Seed sample #: 3458* (auto fill)*
Plant 4 (group 4)
Plant type: A, B, or C* (manually select)*
Seed sample #: 1234 * (manually override, samples were not in
order)*
Plant 5 (group 5)
Plant type: A, B, or C* (manually select)*
Seed sample #: 1235* (auto fill)*
...

I tried using an indexed-repeat but can't get it to work.
In an excel spreadsheet I have the field "seed_sample_number" and in the
"calculate" variable column I have:

"indexed-repeat(${seed_sample_number}, ${plant_group}, (position(..)-1))+1"

But when I try to upload to aggregate I get an error associated with bad
coding.

"Javarosa failed to construct a FormDef. Is this an XForm definition?"

Through my own troubleshooting I've determined that the formula is correct
because, if I create a new field within the group (ex: "test_field") and
put the same formula (still referencing the "seed_sample_number" field) in
the "calculate" column, it will upload. Then when I test it on the device,
I enter a value in "seed_sample_number" (ex: 1001) and go to the next group
and the "test_field" will be auto-filled with 1002! So it works! BUT not,
because I can't get that value in the correct field. Even if I leave the
"test_field" and try and auto-fill the "seed_sample_number" by referencing
the "test_field" I get the same errors.

I also tried manually uploading the XML to my Android device, opened the
form and got the error:

"Dependency cycles amongst the xpath expressions in relevant/calculate"

This made me think the form doesn't know how to calculate the first value
when there is no previous group to reference?

To eliminate that idea, made the formula an IF statement*, where IF the
position number was 1 (first group) then it would return a "0" instead of
running the formula.
*I couldn't find any documentation on writing an IF statement but I think
the syntax is correct.

"if(position(..)>1, (indexed-repeat(${seed_sample_number}, ${PlantData},
(position(..)-1))+1), 0)"

That didn't work. Still got the same errors. I think I'm either going about
this at the wrong angle, and I should try using another method, in which
case I'm open to all suggestions! Or, I'm really close and am missing
something I can't think of.

I attached the Excel file and corresponding XML.

Long-story short:
I'm trying to auto-fill a field in a repeat group, by referencing the same
field in the previous repeat of that group. Currently I'm trying to use the
"indexed-repeat" function, but am getting circular reference/dependency
cycle errors.

Thanks!

plant.xlsx (10.4 KB)

plant.xml (3.25 KB)

··· > Further break it down for me. I will and can be of help. > Plant types are select1 and when 1 is selected Seed sample should auto > fill (using acknowledgment ) a fixed integer figure or random, right? >

Did you manage to resolve this issue?

This is fundamentally not possible with XForms as implemented in javarosa.

You are seeking to set a 'default' value that can be overridden or
accepted, but defaults are not available in ODK Collect except as values
supplied in the form definition and, for repeat groups, identified with a
jr:template attribute.

In these cases, they can only be constant values -- not functions.

··· On Fri, Sep 26, 2014 at 3:24 AM, DamianLindley via ODK Community < opendatakit@googlegroups.com> wrote:

Did you manage to resolve this issue?

--

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