Hey everyone! I'm relatively new to using Survey123 and XLSForms, so I'm going to ask a question that's been asked a million times before, I'm sure, but I did a lot of looking around and my understanding of how Survey123 & XLSForms is so un-sophisticated that I was just getting lost. Apologies for being repetative here.
Problem statement: I want to do a multiple level lookup so that when I select "Job", "Phase", and "Team member" that my next drop down has the default value for that person's role on that job and phase, BUT if a user wants to change their role, they can, using a drop down.
My effort so far: I created a CSV file that will have all the jobs and all the phases and all the people (right now it's just a sample set for testing), and then created a column that concatenated those and assigned them each roles. Again, right now this is purely dummy data for testing.
In my XLSForm, I have a drop down for job (general_job), a drop down for phase (general_phases), and a drop down for people (labor_level1). Next, I created a text field that displays a concatenation which combines the displayed labels for each of those things, using the jr:choice-name command:
Everything so-far, so-good.
My next step was to add a calculation to the dropdown question and ideally it should work. One thing to note is that I'm still going on displayed values rather than the name, because in the CSV I don't want to have to include the funny name of the label.
However, when I put in the pulldata calculation into the role selection question, I'm not getting any response. Nothing. I even tried copying the calculation into a text field to see if there was some conflict between the possible values in the drop down vs the values in the CSV file, but still nada.
I'm attaching the XLSForm and the CSV to see if you guys have any ideas. Thanks again for your help!
Okay, so I now have it mostly working. I didn't know the file needed to be in the media folder. My only issue is that even though the looked up value is in the CSV as an exact copy as the lookup from the XLSForm, it's throwing an invalid value error. See this screenshot.
Maybe I'm a bit confused, but I'm not able to reproduce the error you're showing. The "select their role" field populates with a string like "Test 18" based on the concatenation from previous fields. Do I need to do something different to try to replicate exactly what you're getting?
There may be something related to labels vs. names here?
Also, you've probably already referenced this, but just in case, this is a fantastic post about pulldata from James Tedrick.
Okay, here's the updated files with the actual names instead of Test names. The goal here is that the drop down will be pre-populated with the person's listed role in the CSV, but if the survey user wants to change their role, they can do so. So the role label in the CSV and the label in the drop down menu need to match - which in my example, they do.
Ok, so I downloaded the attached version of the Survey and CSV, and set it up on my machine with Survey123 Connect v. 3.12.232. It seems to be working fine for me: when I choose values from the dropdown, the role auto-populates with the text in blue:
If I manually change the role after that, the text changes to black (which implies it should still be a value that the survey will accept).
Do you experience different results when you test the survey in Connect on your machine?
Also, unrelated to your initial post but I have some (admittedly unsolicited) feedback for the user-interface of your survey, since you said you were so new to it. I would recommend having the date question have a default value of today() or now(). Just one less "click" for the field worker to have to do! (They could easily still change the date if needed).
I'm on the version Survey123 Connect Version 3.13.251 (maybe it's a version issue?) , and am getting red text when I go through the same procedure you listed above. See this screenshot:
Regarding your side note - I might add today as the default value, but the SME I'm working with suggested he wouldn't want people to make the mistake of not picking the right date, so we've avoided a default value there, for now.
That is very strange, if you're getting different results running the exact same survey XLS form on the same version of S123 Connect. Maybe try experimenting with removing the jr-choice-name and see if it works?
Another suggestion would just be to try building a brand new survey using the same schema, sometimes that helps to reset things or at least test to see if it behaves differently in a new survey.
Also, totally makes sense about the date field!
Starting fresh didn't work. 😞
When you suggest removing the jr-choice-name ... where do you suggest removing that? Wouldn't that load the Name... which isn't in the dropdown?