Salesforce is a customer relationship management tool (CRM), which is used to help companies manage and promote the relationship with existing clients, and develop new clients. It runs on cloud, so there is no need to install any software and no hardware is required. Apparently, it reduces the development cost and can deliver an application in a very short time. Currentl, Salesforce is a leading on-demand CRM in market. Thus, integration with Salesforce is more common when we build sites or systems. This series of articles mainly focuses on how to integrate AEM with Salesforce from AEM’s Cloud Service and its OOTB component to custom components with the Salesforce API.
I noticed that Adobe AEM already provides its extendable capabilities (Cloud Service) to integrate with Salesforce and it also provides OOTB components to show data from Salesforce. There is an article on this topic on its helper hub. However, this article is not a perfect one, there are some mistakes that may prevent developers from a successful integration. Thus, I wrote this article to show the correct steps. I hope this article may help you when you are trying to get the AEM Cloud Service to integrate with Salesforce.
Configuring AEM to integrate with Salesforce
You will need the customer secret and customer key to remote login to Salesforce. Salesforce provides an application named Connected App for remote access. In AEM, it provides Salesforce Cloud Service to config integration with Salesforce.
1.Create a Connected App in Salesforce
Login to your Salesforce org.
Navigate to Create -> Apps.
Click the new button in Connected Apps section to create a new one.
Fill in required details as shown in below images. The callback URL here accepts only HTTPs URLs, so AEM must be SSL configured. The callback URL is the URL of the cloud service that we will create in AEM.
2.Configure Salesforce Cloud Service in AEM
Go to Cloud Service. In Third-Party Services, click Configure Now in Salesforce.
Create a new configuration and get the application URL, which is the Callback URL in Connected App configuration.
Fill in the customer key and customer secret that you got from Salesforce Connected App.
3.Connect to Salesforce
Click Connect to Salesforce button and the below module pops up.
Then a confirmation dialog opens to tell that the connection succeeded.
Try the OOTB component in AEM to access data in Salesforce
There is a OOTB component named Salesforce.com Search in AEM, which shows how to use Salesforce REST API to access salesforce objects.
1.Set the created Salesforce Cloud Service onto your site
Then, you will get the matched Lead data from Salesforce.
- The Callback URL should be https. Therefore, you have to enable SSL on AEM. To learn how to enable SSL, please refer to this blog.
- What to do if you are getting the below error while connecting to Salesforce.
One possible reason is that you are trying to login to a Salesforce sandbox. Salesforce sandbox has a different login URL (test.salesforce.com) from Salesforce developer and the production environment(login.salesforce.com). However, in AEM, the salesforce connector sets the authorization URL to https://login.salesforce.com/services/oauth2/token. So, for a sandbox environment, please change this value to https://test.salesforce.com/services/oauth2/token in /libs/mcm/salesforce/components/salesforcepage/dialog/items/tabs/items/basic/items/authorizationUrl.