Yesterday I wrote about getting IoT Data into Heroku. It’s pretty cool, but other than looking at a Heroku PostgreSQL Dataclip, there’s not a lot you can do with the super simple IoT host app I built. Which made me wonder:
OK, I have the data. Now what?
Well, my usual tool of choice is Force.com, but this kind of high-frequency, low-difference data doesn’t work well when fully imported to that environment. This got me thinking about two relatively new and completely exciting things: Lightning Connect and Heroku Connect External Objects.
Lightning Connect (earlier blog, cool tutorial) is a product that includes external data in Salesforce by reference — the data is accessed via the OData protocol and is never copied into your org. Hence it does not count against storage limits. Heroku Connect (Pat’s awesome blog) is all about easy data synchronization between Salesforce and a Heroku PostgreSQL database. But Heroku Connect also includes an External Objects (@vzmind‘s awesome blog) option that publishes any Heroku PostgreSQL table you request in OData format.
So, um ….. HOLY SHIT I WONDER IF THIS WILL WORK.
I started by adding the Heroku Connect add-on and then opening it.
heroku addons:add herokuconnect heroku addons:open herokuconnect
Heroku Connect demo edition is free, which is great, but you’ll need to file a ticket to have External Objects activated. Once that is done it’s super simple. Note: External Objects are activated per app, not per user. If you create a new app, you’ll need to request them again.
Start by creating a connection:
Next initialize your username and password. These will come to your email.
You’ll now see your OData URL as well as a list of tables you might want to share. Note that the listing of available tables appears to be an asynchronous process — it takes a minute for them to show up. Grab a cup of coffee. Then check the ones you want to share.
External Data Source configuration is super easy (with many examples), the only difference here being that the Identity Type is Named Principal and the Authentication Protocol is Password Authentication. Settings example below based on my setup.
And now we have the Heroku Readings object in Salesforce!
Which is super cool. But we can make it cooler by connecting this IoT data with something meaningful in Salesforce. For example, a Device record. As long as I have an External ID field on the Device, I can create an Indirect Lookup between that Device and the Heroku Readings by modifying the Reading’s “Device Name” field type.
And now we have live IoT data meaningfully connected to Salesforce data without importing it and using up storage.
Which, I gotta say, feels pretty much like a HOLY SHIT moment to me.