Accessing External Data from Salesforce.com
You can do cool stuff using “External Objects” in force.com - namely, access the data from force.com application through yet another tab.
If you think that is cool, this post is indeed for you. If not, you can always read this through and get something to scoff at.
But first -
Why external objects or data sources are important?
Well, you cannot have all the data in this world residing in your salesforce.com or force.com database. Regardless of how great force.com is, it will be sometime before consolidating all your business applications on that platform. And even after doing that, you might have that one weird data source refusing to be complaint.
Data external to a system was a reality a decade back, and will continue to be relevant in the future. The only thing that will change is how easy and seamless will be the interaction between the systems.
This is where external object capability on force.com steps in.
External Objects in force.com
You will use external objects to source data from external systems and display the data in a tab. The data is temporarily stored within force.com database, but it will remain the sole property of the data supplier.
You can do the following data operations through External Objects -
- Access data through force.com UI and APIs
- Access data from SOSL and SOQL (no aggregation possible)
You will not be able to do any analytics on the external data.
Configure External Data Objects
Since we are now experto-papyrus (experts on paper) on the theory of External Data access from force.com, it is time to see it in action.
- To get that data, you need the source system to be accessible via the internet or from force.com application. If you are behind a firewall just make sure force.com queries are allowed through.
- External data source should support the authentication that force.com can use.
- Supported formats are Atom and JSON, so don’t expect to do miracles with any other data format.
I ran through this quick check list and can see that our favourite NorthWind database on oauth.org satisfies each of the criteria.
Create External Data Source
As a first step, we create the data source that will be used by our External Object.
Navigate to Develop | External Data Sources.
Create a new entry and fill in required information.
We select the format as AtomPub since that is what is supported by our NorthWind data source on oauth.org.
Hit save, and in the subsequent screen click on “Validate and Sync” button.
Since we want to sync everything available in North Wind, we just select all data fields available. If the data source changes in the future, you can always go back to the External Data Source in force.com and hit “Sync” button again to get those changes to force.com.
You will see that this simple action of clicking the “Sync” button brings the structure of data sources in external system to force.com.
Create External Object
Navigate to Develop | External Objects. You will see that the objects have been automatically created because of your previous action.
You can edit these External Objects just like regular force.com objects, and make any changes as necessary.
The wizard not only creates the data model within the force.com application, but also the UI. You can either customize the pages, or add custom tabs based on the external objects.
The tab shows the external data right within the force.com application. You may need to refresh the view the first time around though.
Note that the external data will not have a salesforce.com id, but only the external id. The URL takes you the actual data supplied by the source system. Drill down on the external id to view the details sourced into force.com application.
What is the use of External Objects?
You can use External Objects to show transient data from third party sources into force.com application.
The data is only temporarily stored within force.com application, and that coupled with the fact that you cannot update the data, will limit the kind of use that you can put this to.
But you could use this these objects to show contextual information for salesforce objects, and quickly provide access to the details. Be wary of performance implications though.