If your organization has already subscribed to the Lighting Connect feature(This is available based on Subscription with additional fees .Contact your salesforce AE to learn more ) to create External Objects,it is good to know that apex can be used by your developer to expose data from any system which uses SOAP or REST as external Objects .
The below shows the video on how Admin will configure with simple clicks for magic
The advantage of using External Objects will be saving some storage space .The data will not reside inside salesforce but can be viewed in salesforce User Interface just like any other objects .
There are number of limitations worth noting before you decide to go with external objects and salesforce documentation can help you in regards to this
There are lot of chances that you need data only for reading from external system and may later run apex to convert few into transaction data .One of the ways to address this business use case can be using lightning connect .There may be millions of data and with lightning connect you can keep it outside salesforce but still use salesforce interface to view ,search and use apex to convert some to SFDC native objects .
When lightning connect feature was launched you needed an adaptor to convert data into Odata before you could actually consume and bring into salesforce as an external object.
Its good to know you dont need an Odata now and an apex written by developer can be used by salesforce administrators to bring any data via SOAP or REST to salesforce .
Aim of the blog Post:
The main aim of this blog post to show an example to developer community on how to extend data source provider and data source Connection classes to build external data source in salesforce.
We will connect to a simple REST end point available for Non commercial financial purpose .To explore more about this webservice please read below
Exchangerate Lab provides us free end point for non commercial use to fetch some data that shows latest currency rates for selected Currencies .Please note the aim of calling this webservice is just to demonstrate the Lightning connect feature.
- The first step is to create a DataSource Connection class.
The Connection class will provide
- Metadata definition of the external schema which admin of salesforce will generate based on need by just clicking a button
- Query method to query the data from API.
- Search method to implement the search via global search
- Filters and pagination if needed can be implemented in query and search methods
- Write a JSON parser for mapping data to fields
The below code is self explanatory and it connects to exchangedate labs to fetch currencies and exchange rates
- The next step is to create a Data source Provider class that describes the functional abilities like authentication mechanism ,capabilities provided by the data source
The below code shows an example class and format