Select to view content in your preferred language

Survey123 version 3.12.274 Pulldata() functionality changes?

14147
49
Jump to solution
02-25-2021 09:37 AM
BamJam
by
Regular Contributor

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

Tags (2)
0 Kudos
49 Replies
JohnWatson_EBA
Regular Contributor

@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!

0 Kudos
ZacharySutherby
Esri Regular Contributor

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

Thank you,
Zach
0 Kudos
JohnWatson_EBA
Regular Contributor

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!

0 Kudos
MathieuBoonen
Regular Contributor

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

0 Kudos
ZacharySutherby
Esri Regular Contributor

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

Thank you,
Zach
MathieuBoonen
Regular Contributor

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

0 Kudos
ZacharySutherby
Esri Regular Contributor

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

Thank you,
Zach
MathieuBoonen
Regular Contributor

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) :?

0 Kudos
MathieuBoonen
Regular Contributor
I was just wondering if you could help me on a slightly different issue . I have a pulldata request in javascript for survey123 that pulls from a XML service  that is found on http://hilltop.gdc.govt.nz/data.jts?service=hilltop&request=GetData&  with a bunch of parameters for site (e.g. Wakaroa Trig) ,measurement (Rainfall)  from date (4/8/2021) , to date (9/8/2021) , interval (5 days) , summary interpolation (total)
the result creates an un-formatted xml  output
i have been able to see the output using 
weather_json = (xmlhttp.response.GetResponseStream());
which I believe is not quite the correct syntax or function to call the object especially when the data is xml as opposed to native json (by the looks) I couldn’t get Json.PARSE or JSON.stringify to retrieve anything I have tried a few similar w3 json functions . As I am not a json guru it’s pretty much new to me.
 
however with the ….GetResponseStream (Did work last night not so much today ) to display the results in the survey123 but only after saving the script, (I assume that it needs an on click type function to invoke the call )form via the form p”but how? realistically All I want from the data is the second object value <E><></><I1> value </I1></E> returned. and maybe a validation that it is Rainfall from the site chosen 
I just don’t know if json is rendering the string into objects that it can find or how to get that in the last step.
 
The ultimate may be one step further in that I find a way to find the closest rainfall sample  point with current data in relation to my current location and use that data instead of having to define the site. from a select_one site request 
 
I believe that I am close but I just need a bit more guidance to get it right. I will add the code shortly 😁 thanks in advance for putting up with this newbie!!!
0 Kudos
MathieuBoonen
Regular Contributor

As promised the SUrvey123 survey plus scripts😎

0 Kudos