Register an External Service
Learning Objectives
After completing this unit, you’ll be able to:
- Define a Named Credential for your external web service.
- Add an external web service using a provided schema.
- Explain how the External Service actions relate to the schema definition you use.
First things first: Named Credentials and Endpoint Access
Before we enter the world of External Services, we have some prerequisites to complete. In the past unit, we covered schemas and what constitutes a valid and supported one for External Services. In addition to a supported schema, we need a simple way to secure our external web service and our Salesforce org. For this task we can use Named Credentials to authenticate our endpoint callouts.
- From Setup, enter Named Credentials in the Quick Find box, then select Named Credentials.
- Click New Named Credential.
- For Label, use Bank.
- For URL, use https://th-external-services.herokuapp.com
- Leave other fields as they are and click Save.
Use the External Services Wizard to Register Your Web Service
Now we get to register the web service. Because we have a valid schema (a real-world example would additionally set the authentication protocol in Named Credential), this part is simple. Adding our Acme bank external service in External Services tells Salesforce how it will interact.
- From Setup, enter External Services in the Quick Find box, then select External Services.
- Confirm Enhanced External Services toggle is set to On.
- Click Add an External Service.
- For External Service Name, enter BankService (no space).
- For Select a Named Credential, select Bank.
- Select Service Schema Relative URL, and enter /accounts/schema The full URL from our service provider is located here: https://th-external-services.herokuapp.com/accounts/schema
- Click Save. Take a look at the External Service Actions and when you’re ready, click Done.
A list of your External Service actions appears. Use the scrollbar to view them all.
These actions are now available to you in Flow Builder. We’ll create a simple flow in the next unit and show you how to find the actions in the Flow palette. For now, let’s look at the getAccount method and some of its parameters.
- The getAccount method retrieves account information.
- The accountName parameter specifies the account.
- There are several output parameters for the getAccount method, too. The codes, such as 200, correlate to specific response codes defined in the schema. You can also see these definitions nicely formatted in the Swagger Editor when you validate the schema.
- An external services provider such, as a bank, shares their REST-based API schema specification: We got this information from our fictional bank.
- Based on the specification, the service provider (like our credit service example) a developer (or maybe you) creates a JSON-based schema definition that describes the API: While we didn’t create this schema ourselves, we reviewed the elements of a schema and the requirements for a supported one. When you work with external services, you or your developer can define the schema you need for your use case.
- A Salesforce administrator declaratively creates a Named Credential to authenticate to the service endpoint using the URL provided by the external service provider: We defined our named credential, https://th-external-services.herokuapp.com.
- A Salesforce administrator declaratively registers the service and uses both the schema definition and Named Credential during the registration process: We just registered our first external service and looked at the actions in the wizard.