Integration with Salesforce Lightning External Services
Author
March 14, 2019
Nowadays there is an API Integration in almost every org. The main purpose of integration with another service is to avoid reinventing the wheel. However, the development effort that is required to integrate with services is a complex and time-consuming venture. It reduces speed to market, but it also saps developer energy that is better spent in the front end, building the features that will really differentiate their app. With Lightning External Services, Salesforce makes this a lot easier and admin friendly.
With external services, you can connect to any service that you want to, invoke methods based on the external source via a flow all with the help of an easy-to-use wizard. Declarative tools are used to import API definitions right into Salesforce. Swagger or Interagent-based API definitions can be used to define an external service. Once the definitions have been imported, you can create lightning flows that will invoke actions generated from the API definition schema. Below is a depiction of how external services work.
Here is what is happening in the above image:
Based on the provided API schema specification, a schema definition is created that describes the API. Once this is done, named credential is created to authenticate to the service’s endpoint using the URL provided by the external service provider. The endpoint is a URL that exposes the web services resources that External Services needs to interact with. Using the named credential and schema definition, external service is registered. External Services imports the definitions into your org and generates Apex actions, which are available immediately in Lightning Flow. While creating a flow, these Apex actions are added into the flow which sends a callout to the endpoint, and output is returned based on schema definition.
Schema Definition for your external service:
Schema specification is basically a contract that contains which type of inputs and outputs can be included in the API calls that are made from your external service. Endpoint information and authentication parameters for REST based API service are also included in specs. On the other hand, schema definition is human readable structured data.
Below is the schema definition of a pet store Swagger API.
This schema declares various methods available in the API and the inputs, outputs included in this service. For example, the below snippet contains information about a GET method which is used to get all the inventories by status.We will be using the Pet Store Schema to illustrate the whole external service in this blog.
Registering an External Service:
Registering an external service involves the below two steps:
1. Named Credential: In order to register an External service, you need to create a named credential first. Named credential is created to authenticate to the service’s endpoint using the URL provided by the external service provider. Create a Named Credential as below in your org:
- For Label, use SwaggerPet.
- For URL, use https://petstore.swagger.io
- Leave other fields as they are and click Save.
2. External Service: In your org, go to setup and search for external service in the quick find box. Create a new external Service and provide the below information in the fields:
- For name, give ExternalSrv1
- For Named credential, select SwaggerPet named credential created in the previous step
- In the Service Schema Relative URL field paste v2/swagger.json
The generated actions are used in the flows. Below is the list of actions available in the pet store endpoint. We cover getOrderById action in this blog.
External Services inflow:
Apex actions generated from external services can be used in lightning flows. When users run the flows, during runtime external services sends a callout to the service’s endpoint. Create a new flow and drag the Apex Action element. Select ExternalSrv1_getOrderById__Service
This action takes an Order id (any integer between 1 and 10) and returns details for that order like Order quantity, pet id, shipping date. Create variables for input and output data and configure the output variables to be stored in the variables as done below. Provide the default value of id such that 1<=id<=10. Set the input values and the output values by associating each with a flow variable. Make sure that the data type of input/output matches the input/output specs mentioned in the schema definition.
Connect the Apex Action with the start element.
After completing all these steps, click on debug. Doing this will start the flow in debug mode. On the next screen select Show details of what’s executed and render flow in Lightning runtime and click Run.Above is the output of ExternalSrv1_getOrderById__Service for order Id = 2. Similarly, other Apex Actions can also be invoked using external services and flow without writing any code.
Summary:
External services are a great tool which along with point-and-click automation tools like flows and process builders can be used to integrate any API with Salesforce without writing any code. It reduces the development effort and is very much admin friendly making the process of integration making this process simpler and thus cheaper.
Pranshu Goyal, Director of Products at Mirekta, states: “We envision DSM to be used by every small to a medium-sized organization dealing with bad data and want to get rid of duplicates easily with no cost. We have faced issues dealing with duplicates in our organization. That inspired us to make a solution that is not only simple to use but can be used widely to make the organization’s data clean to make them more efficient and productive. We want DSM to be a solution for every organization looking for duplicate management capability better than the Salesforce out-of-the-box solution with no additional cost.”
Recent Posts
-
Leveraging AI to Enhance Sales Effectiveness13 Mar 2025 Use-case
-
Revolutionizing Manufacturing with AI: Predictive Maintenance, Supply Chain Optimization, and More11 Mar 2025 E-Book
-
NetSuite for Manufacturing: Streamlining Operations and Solving Key Challenges07 Mar 2025 Blog
-
How to Build Your First Agent in Salesforce Agentforce24 Feb 2025 Blog
-
ERP vs Salesforce Revenue Cloud: Which One is Right for Your Business?24 Feb 2025 E-Book
-
Revolutionizing Manufacturing with Salesforce: A Playbook for Efficiency & Growth18 Feb 2025 E-Book
-
Salesforce 2025 Game-Changing Trends You Need to Know28 Jan 2025 Blog
-
Agentforce 2.0: Everything You Need to Know About the Latest Update22 Jan 2025 Blog
-
The Ultimate Guide to NetSuite Development: Tools and Techniques10 Jan 2025 Blog
-
How Salesforce Nonprofit Cloud Transforms Fundraising Strategies10 Jan 2025 Blog
-
The Impact of Salesforce Development Partners on Small and Medium Businesses08 Jan 2025 Blog
-
Key Questions to Ask When Hiring a NetSuite Development Partner08 Jan 2025 Blog
-
Salesforce Agentforce Demystified: Your Essential Guide08 Jan 2025 Blog
-
Salesforce and NetSuite Integration: Driving Business Efficiency with Precision06 Jan 2025 Blog
-
Everest Group has positioned Mirketa as an Aspirant in the report24 Dec 2024 Press Release
-
Salesforce Einstein20 Dec 2024 E-Book
-
Order to Cash Cycle with NetSuite20 Dec 2024 E-Book
-
Empower Your Marketing Strategy with Salesforce Marketing Cloud's Automation Studio Activities13 Dec 2024 Blog
-
Salesforce CPQ for Subscription-based Businesses10 Dec 2024 Blog
-
Unleashing the Magic of Einstein Prediction Builder10 Dec 2024 Blog
Categories
Featured by



