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:
- 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_")
-
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.
-
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
- Using these new variables in the child form, I populated the choice list like this:
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!