Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Grab data from url?
Tagged: URL
- This topic has 3 replies, 2 voices, and was last updated 5 years, 10 months ago by Brendan.
-
AuthorPosts
-
January 14, 2019 at 10:26 AM #33427
Steve SmithParticipantUsing the latest version on iPhone/iPad…
Is it possible to have a field/button that grabs data from a particular url?
For example, when the button is pushed, TF uses your position to look up and grab the current weather.
This is the .xml weather feed for an example location:
https://w1.weather.gov/xml/current_obs/KFFZ.xml
This is the raw weather feed for an example location:
https://w1.weather.gov/data/METAR/KFFZ.1.txt
It is also possible to get the data via ftp or an api, example:
http://samples.openweathermap.org/data/2.5/weather?zip=94040,us&appid=b6907d289e10d714a6e88b30761fae22
api call via coordinates:
http://samples.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=b6907d289e10d714a6e88b30761fae22
Possible?
January 14, 2019 at 7:44 PM #33430
BrendanKeymasterHi Steve,
Sure, you can do that using the Script feature. You need to know a bit of JavaScript, but there are functions to get data from a URL.
See the docs for the JavaScript API:
https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api
Also there’s a sample script on this page that shows you how to get JSON data from a URL:
January 20, 2019 at 8:51 AM #33500
Steve SmithParticipantQuestion: how does the ‘script field ‘ know the gps coordinates of the phone? I have a Location field in the form already, can the script field use that? Or can the script grab the gps coordinates itself from the phones gps?
Also, I cannot write code, a friend will be writing this script for me. I will send him the script page link you posted above, and he has already looked at the NOAA api documents. He does not have TF, will that be an issue?
January 20, 2019 at 7:56 PM #33503
BrendanKeymasterHi Steve,
You can access a Location field value from a Script field. The location field value will end up being a dictionary that you can reference like this:
var location_field_id = 'fld....'; var location_value = record.getFieldValue(location_field_id); var title = location_value['title']; var latitude = location_value['lat']; var longitude = location_value['lon']; // now you can do whatever you want with the values
The script can only get the values from a Tap Forms field. It doesn’t have a way to get the geo location coordinates itself. So you just need to add a Location field to your form and then let Tap Forms get the location for you for that field. Or of course you can set it to whatever location you want. Now once you have the location value, then the script can get access to the data.
Your friend will need Tap Forms because there are specific Tap Forms functions that he’ll need access to.
-
AuthorPosts
You must be logged in to reply to this topic.