Reid Carlberg

Connected Devices, salesforce.com & Other Adventures

Simple Salesforce Lightning Connect Example (External Objects)

13

Lightning Connect includes External Data Sources and External Objects.  You can try this in your free developer edition. There’s a nice blog that talks about setting up a more custom data service and covers a bit more about why this is super cool.  Andy Mahood also blogged about this recently, including more details on related lists and Chatter.

Lightning Connect is the new service from Salesforce that lets you bring OData content into your Salesforce org. I was curious how to test it, so I thought I’d share what I found.

Step 1: Locate Sample Data

OData is a protocol for exchanging .. er … data, so it makes sense that you could probably find some sample data to connect to. A bit of the old Google led me to this sample data page where you can click on a tab to see “V2” sources.

salesforce-sample-odata

When you click on the Northwind sample, you get a bunch of XML (hooray). You’ll want to copy the URL in your browser window at this point.

salesforce-sample-odata-xml

Step 2: Create a new External Data Source

Back in your free developer edition, navigate to Setup > Develop > External Data Sources, and fill in the form as shown in the image. In the Server URL, paste the .. er … server URL you just copied above.

salesforce-external-data-source-new

Important: once you click “Save” you then need to click the button that says “Validate and Sync” before you can move on.

salesfroce-external-data-validate-sync

Once that’s complete, you will be able to select the specific object you’re interested in. For this example, select “Categories” and click on “Sync”.

salesforce-external-data-select

After a moment, you will return to the external data source screen and your external objects related list will look like this — sweet!

salesforce-external-objects-related-list

Step 3: Create a Tab for the External Object

If you click on the “Categories” label in external objects related list, you’re going to see an object definition screen that looks shockingly familiar. Yes, it even includes a “Page Layout” section at the bottom.

salesforce-external-object-definition

Adding this to a tab is super easy. Navigate to Setup > Create > Tabs, and create a new tab for a custom object. That’s it!  Now you can easily navigate to particular records, work with list views, etc — all of the stuff you can easily do with custom objects.

salesforce-external-object-related-list

Step 4: Do a SOQL Query

If you’re like me, you are by now fairly curious about accessing the data in Apex and in a standard SOQL query. Head on over to Workbench. When you login, be sure to login using v32.0. Jump to SOQL queries, and select the “Categories__x” object.

workbench-SOQL

And in the .. er … category of least surprising thing ever, you can see it works!

workbench-soql-results

But what about Apex you say? Yes, also just that easy, as you can demonstrate for yourself using Workbench’s Apex Execute utility.

workbench-apex-execute

Pretty Sweet!

Give it a shot and let me know what you think. @ReidCarlberg

 

 

 

 

13 thoughts on “Simple Salesforce Lightning Connect Example (External Objects)

  1. Robert Prynn

    Can you make show a watch app demo/use for a future blog??
    This article really pointed me to some cool stuff that you can do to extend your iPhone app to you watch interface via the WTK.
    11 things we just learned about how the Apple Watch works
    Any thoughts?
    Leveraging SF1 with a device like that could be really game changer IMOP.

  2. Chirag Mehta

    great post, detailed and thoughtful one!

    What about future updates ie if data model (attribute) changes at ODATA level, will sync bring those changes back into Salesforce ?

  3. Pingback: Access IoT Data in Salesforce using Heroku Connect OData | Reid Carlberg

  4. Sara Morgan

    Hey Reid,

    I am trying to do a relationship query with some related external objects and I cannot figure out how to do it. The docs say that “Each SOQL query can have up to 4 joins across external objects and other types of objects.”, but if I define an external source that has 4 tables that are related and then look at the objects through Schema Explorer in the Force.com IDE and I expand the relationships node, it shows EntitySubscriptionFeed and not the actual child table that it should. My guess is that a relationship query is not possible, but I cannot find any examples out there with anyone trying to perform one. I was wondering if you had tried and what your experience might have been.

    Thanks,
    Sara

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: