Using dynamic data attachment to populate choice lists for select_one and select_multiple fields

Hi there,

I want to know if there is any update on this topic.

I am linking a child project to a parent project using the Dynamic Data Attachment feature.

In my chlid project, I want to appear others questions based on the anwers to a select_one or select_multiple question from the parent project. When referencing an answer to a choice question in the child project to use it in the relevance syntax for a new question, the choice made in the parent project doesn’t appear while it works perfectly when referencing questions of text and integer variables types.

Can anyone tell me how to solve this issue ?

Kind regards.

Hello,
could you share the related parts of the two forms: the questions, incl. the reference and the relevant clause (in XLSForm), please?

1 Like

Agreed! Using an external csv seems to defeat the purpose of having a dynamic connection between projects,
Upvoted as I hope this can be included in future developments!! Thanks for the work.

1 Like

Hey everyone,

Any news on this much-appreciated update?

Thanks to the team,
Best,

Welcome to the community, @meal_team_palma! The feature is still not supported yet!

Hi All,

I am new to KoboToolBox, and am trying to create parent-child forms that will do exactly what this thread is about: generate and automatically update choice lists for a select_one question in a child form given new responses to a text question in the parent form. For example, users write in a respondent name or id in a parent form, and then in the child form can select one from a list of respondent names or ids.

This seems to be the same issue referenced in this post: Pull data from Parent project for select_one or select_many choice list - #3 by darrenk

What is the likelihood that this feature will be added in the near future? Thanks so much!

Welcome to the community, @DanielJohnRead! It’s one of the most requested features with the Dynamic Data Attachment. We could put this in the features development list if someone were willing to sponsor this feature. Are you or someone from this community interested? If yes, please feel free to reply. Your small contribution would make a significant impact on KoboToolbox.

Hi @Kal_Lam! Thanks so much for your reply. As I’m still new here, can I ask what exactly it means to sponsor a feature, and then how much it would cost and how long it would take to get this feature developed?

1 Like

@DanielJohnRead, thank you for getting back to us. If you are still interested in sponsoring this feature, please reach us through info@kobotoolbox.org. We could then share the quote and the tentative time to develop this feature.

This would solve the majority of the limitations to perform a complete longitudinal survey! Hoping to hear some good news on this front soon!!

1 Like

Welcome to the community, @tharindu! Please feel free to sponsor this feature to see it being integrated into the system.

any update about this ?

Dear all, we would also appreciate if this feature will get integrated soon.

Is there a way to sponsor the development of this feature commonly by all parties interested and willing to share the costs?

Dear All,

I had a conversation with a KoboToolBox representative several months back, and the issue is in how XLSForms are structured. Options for choice_lists are baked into the XLSForm that is uploaded to KoboToolBox/ODK. These XLSForms are independent of the data that is entered into the form, and the two do not communicate with each other. Because of this, implementing this feature likely requires a heavy restructuring of how XLSForms work with Kobo/ODK.

I did receive a price estimate for this change, but I’m not sure it is appropriate to list publicly, though @Kal_Lam, please correct me if I am wrong. Suffice to say, unless several people have grants that they’d like to pool, or if we get thousands of people to pool their own money, this is likely out of reach.

Dear DanielJohnRead,

I also asked for a quote, but still waiting. I think this is an important limitation to Kobo, that should get resolved. Because maintaining manualy always changing csv files is not efficient. I am not an technician, so I cant’t really judge on the difficulties. But since it is possible to retrieve information from another object it should – i think and hope – be possible to make them available also in form of a select_one or so list.

Hi everyone, I just wanted to share a workaround that I used to make this work, even without being able to directly populate choice lists using another Kobo form. I used this strategy to populate a list of products for a given company, pulling the list from a Kobo form called “product list.” Here are the steps that I took:

  1. In the parent form (product list), I had a field for the company and then fields for the name and label of each product. The label was the name of the product as entered by the respondent, and the XML name was calculated based on this label (removing capital letters and replacing spaces with underscores).
translate(${full_name1}, "ABCDEFGHIJKLMNOPQRSTUVWXYZ -", "abcdefghijklmnopqrstuvwxyz_")
  1. The dataset for the parent form therefore included the following variables: company, product1_name, product1_label, product2_name, product2_label, etc. There was one entry per company.

  2. In the child form, I pulled in those variables with dynamic linking and using company as the identifier. I.e., if Company A was selected, the form pulled in names and labels for product 1 through 5 for Company A.

instance('products')/root/data[company = current()/../company_name]/product1/name1
instance('products')/root/data[company = current()/../company_name]/product2/name2
instance('products')/root/data[company = current()/../company_name]/product1/label1
instance('products')/root/data[company = current()/../company_name]/product2/label2
  1. Using these new variables in the child form, I populated the choice list like this:

Screenshot 2023-11-13 at 12.58.55 PM

The main limitation to this approach is that you have to account for the maximum number of options that can be pulled into the form, as you need to manually import each option as a new variable. In my case, I knew there would be a maximum of 5 products, so I built the form to import 5 products, but I added a choice filter to hide options if they were empty (i.e., only show 4 if only 4 products were entered).

Hope this helps!

5 Likes

@ salomegarnier,this method is a nice workaround.

1 Like

Thanks for sharing,
I would recommend to also test the export of the data (XML values and labels, SPSS labels), as the $-reference might not show the replacement.

1 Like

Can you please share a sample xls file for this?

Thank you.

As of now there are two limitation of this dynamic data attachment

  1. There is a delay of about five minutes between a data is submitted and it becomes available for other project (or itself).
  2. You can not display the fetched data as a list and allow user to choose (as the standard concept of foreign key used in DBMSs) instead you will have to enter key in a text box and relevant record(s) will be searched using that key.