A dynamic field name


1. What is the issue? Please be detailed.
I would like use a dynamic name of a field, in odk-xlsform

2. What steps can we take to reproduce this issue?
For example ${my_cell} in "name" column

3. What have you tried to fix the issue?

4. Upload any test forms or screenshots below.
test.xls (10 KB)

I am looking for a solution to use a dynamic field name, It is possible ?


This is an interesting question, however, I am wondering why you are looking for this capability? e.g., what would be the use cases for this?

I don't think this is possible. However, I'm wondering if you can explain your use case, I wonder if there's another workaround possible?

I guess the challenge I see with this is that the 'name' column essentially creates your field/column in your final dataset. If the name is dynamic, then there could theoretically be an infinite number of columns, and all your data will show up in separate/different columns each time a new answer is recorded.

Looking at your example, if you want data to show up in different columns depending on the response given, then you could simply create those column 'names' as different questions in your XLSForm, and then use the 'relevant' column to move data to those different columns.

However, in your example - you've created a 'note' question, which typically doesn't hold any data in the final dataset anyway.

So yes - perhaps you can explain a bit more about what you're trying to accomplish and maybe we can help brainstorm with you!

1 Like

Short answer: you cant. In XLSForm the control name has to be unique. Instead, as your example includes, you can put references to other things in the control label.

[Long answer: In the actual resulting XForms you can actually have an input control ref that is an XPath binding expression, which could conceivably be used to construct a dynamic reference from a control to various instance data nodes at runtime, but [1] this isnt exposed by XLSForm, and [2] off the top of my head I dont know what Collect's OpenRosa XForm processor would do if fed such... @LN? (eg it'd confuse dependency validation to no end) So stick with the short answer: you cant :slight_smile: ]