Hi all,
My goal is to have some questions survey auto filled, based upon the sample ID that is entered or QR code that is scanned (containing sample ID). I have a CSV that will be updated prior to each field outing, and it is uploaded to the media file within the Survey123. When entering data into this CSV for select one or select multiple questions, I am pulling the name of the desired answer directly from the name column of the list in the choices tab. I hope to have the caseid, sampinfo_type, sampinfo_filterps, sampinfo_bpkserial, sampinfo_reps, sampinfo_prestype, sampinfo_targetsp, and contactinfo_org name fields in my XLS form for the Monitoring project type only, auto populated with the values found within the CSV, as these values are project specific (within the choices that are already determined). My main motivation for this is to mitigate data entry errors and make the survey less time consuming for the field staff.
I can get the auto populate to work using this example calculation pulldata('pulldata2026', 'projectname','sampid',${sampID}) (example for the caseid field). I have customized this equation to each unique field, and they have all worked well, however when there is no sampid found matching in the pulldata2026 file (which will sometimes be the case), the survey returns a blank response during submission, even if a custom value was entered.
After some tinkering and help from ChatGPT, I have discovered that I need to add a calculation that works as a conditional statement to allow for a user submission and actually submit this answer. In the newest version of my XLS, attached in this post, I have utilized several lines creating a lookup key, lookup calculation for each field, as well as a final "answer" for each field, derived from the conditional statements. No matter what recommendations I am given, I can't seem to get the auto populate to even work now to see if I can test for the blank response.
Ultimately, I would really like to have these fields populate in the original question boxes and have the ability to edit the responses and have them actually submit if the auto-populate is wrong or no matches are found. Any recommendations would be greatly appreciated.
Have you considered using an "other" option in your list and then a relevant question to fill in the blank if they select "other"? After that you can make a hidden field to hold either the selected answer or the other.
https://doc.arcgis.com/en/survey123/desktop/create-surveys/multiplechoice.htm
if(${Select}='other', ${Select_other}, ${Select})
Hi,
Thank you for your advice, are you suggesting that I implement the "other" option in the sampID field or for some of the other questions?
Thanks!
@spf999 So I think I misread originally, not sure of the exact action you describe, I could not replicate it. But I think ChatGPT was trying to make it more complicated than it needed to be. Attached is a simplified example from the xlsx you uploaded. I think I was able to replicate all your desired functions. When I changed to an unknown sampleID I was able to enter custom values and they remained through submission.
I set the calculationMode=auto, below is the documentation on that. If a custom value is entered, it will not overwrite unless you manually reset it.
I also added a collate field for the filterps questions, note the null field types, the only answer that should be retained in the data is "filterps_collate"
Hope that helps.
Hi @Neal_t_k ,
I used your suggestions in my form, updated, and republished; however, I was only able to prepopulate the caseID using the pulldata function in the Survey123 app and no data was prepopulated in the form preview of Survey123 connect. None of the other fields such as the sample type, filter pore size, and etc, prepopulated. I have not evaluated the prior submission issue as of yet, since I wasn't able to prepopulate my desired fields. Since you got it to work on your end do you think that I am having a formatting issue with my equations, an issue with my CSV, or an issue with Survey123 Connect? I've attached my updated XLS form (with your suggestions) and am still using the same pulldata csv as before. I really appreciate your help thus far in solving this issue!
@spf999 I just opened your form, as is, in connect and the field app and all the fields prepopulated for me when I entered one of your sampleIDs...not sure what would be causing that on your end.
A couple things to check:
-version of Survey123 connect - might as well check you are using the most updated version. Maybe uninstall and reinstall connect?
-verify your CSV column headings are all lower case and that the references in the calculations match.
That's all I have, as it appears to be working as you intend on my side.