Send push notifications with Pushbullet

This example demonstrates integrating Fulcrum with Pushbullet to automatically send a push notification when a record is saved. It uses the Pushbullet API to create a push notification, which includes some record data and a link to the record location on Google Maps. This is useful when you need immediate notifications from the field without having to wait for syncing.

ON('save-record', function (event) {
  var options = {
    url: 'https://api.pushbullet.com/v2/pushes',
    method: 'POST',
    headers: {
      'Access-Token': 'my-access-token',
      'Content-Type': 'application/json'
    },
    json: {
      'email': '[email protected]',
      'title': 'Fulcrum record saved in: ' + this.form.name,
      'body': USERFULLNAME() + ' just saved a record with a status of: ' + STATUS(),
      'type': 'link',
      'url': 'http://maps.google.com/maps?q=loc:' + LATITUDE() + ',' + LONGITUDE() + ' (' + $name + ')'
    }
  };

  REQUEST(options, function(error, response, body) {
    if (error) {
      ALERT('Error: ' + INSPECT(error));
    }
  });
});