Add current weather to a record

Use this to fetch weather data from the API and add it to the record.

This example assumes you’ve signed up for an API key from and have a text field in your app (weather_summary below) to store the current weather summary.

NOTE: Weather Underground API is a paid for service. There are some alternatives below. If you use one of these alternatives, you will likely need to reference their API docs to ensure that the calls are properly configured.

Here we’re listening for the 'change-geometry' event for a record, and then using the REQUEST function to make an API call to Once we get the response we parse it as JSON and use SETVALUE to update the form value.

function getWeather() {
  var apiKey = 'your_api_key';

  var options = {
    url: '' + apiKey + '/conditions/q/' + LATITUDE() + ',' + LONGITUDE() + '.json'

  REQUEST(options, function(error, response, body) {
    if (error) {
      ALERT('Error with request: ' + error);
    } else {
      var data = JSON.parse(body).current_observation;
      SETVALUE('weather_summary', + ', ' + data.wind_string);

ON('change-geometry', getWeather);

If you only want to fetch weather when explicitly requested by the end user, you can listen for the 'click' event for a hyperlink field. Just add a new hyperlink field to your app and give it a descriptive label, “Tap to Add Weather Data” for example. Leave the default url blank and set up your data event like so.

// This assumes you've still got the getWeather function defined from the example above

ON('click', 'your_hyperlink_field', getWeather)

These examples add basic weather metrics, but many others are available and could be added to multiple fields in your app.