Hello Survey123 Community and @JamesTedrick or @IsmaelChivite
We have a form that has been in use for months that utilizes the pull data functionality to populate some fields in the form based on a barcode scan.
We have had several users call that are not getting data populated in those fields after a barcode scan. All our users are using iOS devices. We have isolated this issue to users that have version 3.12.274 of Survey123. We've verified that the necessary .csv file is in the media folder within the Portal item and that the data is properly populated in the file itself. Furthermore, users that are still on 3.11.164 are able to scan and get the necessary fields populated...even after updating the form itself. So, it seems to be an issue with version 3.12.274.
I have not been able to find any information on version 3.12.274. Is there a change in the pulldata() functionality?
Any help would be appreciated.
Thanks,
Brandon
Solved! Go to Solution.
@ZacharySutherby my survey is much simpler, though I do have 3 tables utilizing the pull data function. I don't have any extra fields, weird characters, or duplicate field names. What do you think? Thanks in advance!
Hello @JohnWatson_EBA,
It seems the return column and lookup column are flipped in the pulldata() function. I had switched it to pulldata('Doyle', 'diameter_logs', 'Volume', number(${diameter_logs})) and that worked on my end.
I had added the number() function to ensure that the value passed in matches what's in the CSV.
As a note, not all number combinations return a value for example selecting Doyle, 15, 2 returns a value, but Doyle, 15,1.5 doesn't return a value because 16.5 doesn't exist in the Volume column.
Thank you,
Zach
Thanks, @ZacharySutherby , however, I made the same change you did and the Timber Calculation, Doyle Scale field still did not auto populate. But I see the issue: I want the calculation column for the diameter logs to be, essentially, the values of "diameter" and "logs", as opposed to adding them together. So instead of "10+4" which would result in 14, I want that field to result in "104". how do I concatenate those fields in a calc?
edit: I figured it out. Thanks for helping me get there!
I have a similar issue and maybe it is outside the capabilities of javascript and @json calls from within Survey123, with the attached I have tried various API's ( I'd prefer onecall api) under openweather.org but I cannot get the results I expect for individual values, or maybe I just need to be shown how to extract from the output that actually does work..
The ultimate for me is to read the last 5 days rain as well as the next 7 day forecast and present the results into a ranking of severity to use as a activity planning matrix eg if Main equals Rain then weather rate = 10 on a scale of 1 -10. I have attached the script for the big part will work it is just getting at the individual outputs.
probably javascript against the weather_json (WITHIN THE ATTACHED) code which I possibly need to export to a intermediate table or something. But with no exprience in Java scripting I can only take it so far within getting a better understanding of script functions etc. A full listing of java functions and use would be great.
Any guidance or help would be awesome...
Mat
Hello @MathieuBoonen,
If you are looking for the description from the JSON response you would need to use
pulldata("@json", ${weather_json},"weather[0].description") |
This is because the weather name has an Object nested in an Array. That is why 0 is needed to extract item with index of 0, and the .description is needed to extract the property value from the description property.
Please see the following W3 schools documentation links for more information on JSON Objects, Objects in JavaScript, and Arrays in Javascript
https://www.w3schools.com/js/js_json.asp
https://www.w3schools.com/js/js_objects.asp
https://www.w3schools.com/js/js_arrays.asp
Thank you,
Zach
Thanks Zach
Such a quick reply.
So if there are multiple objects, as in the Onecall API returned response that appears to be in multiple arrays (1 per day) to report items such as "description" do they need some form of index id for each one, i.e. [0] [1] [2] etc. to each reported array.
pulldata("@json", ${weather_json},"weather[0}.daily[0].description" and then ${weather_json},"weather[0}.daily[1].description" |
or if it is an array within an array do they need to be nested in some for of script structure above, of course as separate responses in Survey123.
I will take a look at your resource as provided, so I am preempting that already..
Thanks
Mat
Hello @MathieuBoonen,
The syntax is a little off, given how the Onecall API returns it's JSON if you are looking for the days description the syntax would be
pulldata("@json", ${weather_json},"daily[1].weather[0].description") |
This will return the weather description for tomorrow. If you are looking for other days you would change the index after daily. For example daily[0] would be today and daily[2] would be two days from now.
It also looks like the Onecall API has an exclude parameter so if you are not interested in the minute forecast, hourly forecast, or alerts you can exclude them and make the response smaller.
Thank you,
Zach
Thanks clarifies it immensely , Should have known about the w3 resource years ago, just never had the time but at least sick leave now is good for learning. now onto error trapping objects that don't consistently exist.. (poor Survey123 calculation formula strings) :?